Problem sending SMS or email with sample form

Hi
The external application launch (email and SMS) functioanlity is broken at the moment in ODK collect latest version.

Passing ${send_to} and ${message} as raw strings works but the odk collect application crashes when using variables for $send_to.
The ${message} variable doesnt crash the application but it never gets passed to the external application e.g. SMS or gmail etc.

Please validate if this is a one off issue or fix as early as possible if its pervasive.
Thanks and regards,
Ali

Hi
I am actually using the example from release notes and experiencing the same problem while using the exact form from the release notes. https://docs.google.com/spreadsheets/d/1hep9Ibtd2u3rtPviNn8HS0qbwjGoJy4JtZOn6xdHkMk/edit#gid=0

Any help in this regard will be very appreciated. Thank you.

Can you please both let us know what versions of Android you are using, what devices you have, and what SMS and email applications you are using?

It would also be helpful to know if you see any kind of dialog or message when Collect crashes. I just tried the sample form again and it worked as expected for me. @alios82, did you try the sample form without any modification?

Using Android 7.0 on Samsung Galaxy S8.
SMS Application is "Messages 4.2.03.12"
Email Application is "Gmail 8.4.8.194949231"
I don't get any message when it crashes.

i used:
ex:android.intent.action.SENDTO(uri_data='smsto:5555555', sms_body=${message})
from https://docs.opendatakit.org/launch-apps-from-collect/

i was concating 'smsto:5555555', storing it in a variable and equating that to uri_date. That was causing the crash, then i copied the example from the sample form where the "uri_data" and "sms_body" are flipped e.g:

ex:android.intent.action.SENDTO(sms_body=${message}, uri_data=${send_to})

That worked as expected.

So the example in the documentation needs to be fixed.

1 Like

I'm glad you've got it working, @safi!

I've confirmed that the implementation doesn't expect any particular order for the two values. I tried flipping it in my test form and everything still works as expected. If you can share an XLSForm that crashes, we might be able to identify an underlying issue if there is one.

Thanks LN. You are right it does work both ways.
I think I have finally found the actual problem.
When Send To intent is used in a repeat group, ODK collect crashes. I tried using it in a repeat group, in a regular group and without any groups. it works fine for regular groups and without groups, but when used in a repeat group, ODK Collect crashes.

Also when I tried using the repeat group example from sample form it gave me an error saying

"The requested application is missing. Please Manually enter the reading"

Is there a solution or a way to open up the sms app within a repeat group?

1 Like

Hi @LN
I am using Android 6.0.1 on Samsung galaxy S7 edge.
The resolution mentioned by Safi worked for me.
I was also using sms and email within a repeat group.
It works fine outside of repeat group and independent of order of parameters.

1 Like

Could you share a sample form that has this problem? When using repeats, you do have to be careful about indexing and in general there's more complexity there. I can imagine various reasons why you'd be getting a crash.

Aha! Now this is kind of a bewildering one and might explain why you had different behavior based on parameter ordering. The sms_body value in that sample form is "Thank you we can't wait to see you on the study start date." which contains an apostrophe. It turns out that the code used to separate out parameters treated it as a quote that never got closed and so the uri_data parameter after it wasn't identified. However, if uri_data comes before, sms_body can contain apostrophes without any problems. I must have changed something in the form definition that I thought was inconsequential like the contents of the message or the order of the parameter after trying the form.

For now, I recommend putting uri_data first so you don't have to think about this quirk. I have filed an issue at https://github.com/opendatakit/collect/issues/3711 and hope we can fix it soon.