Survey123 custom JS function failing to pull data from service on a specific device

1422
4
Jump to solution
12-01-2020 12:09 PM
AllenDailey1
Occasional Contributor III

I am trying to help a staff member in my organization who is using a Survey123 survey I built.  She is using version 3.11.164 of the field app on an iPhone XR that was set up and is managed by the organization.  Everything in the survey works fine on people's personal phones, including mine, which has the same app version as hers.  Her coworker is able to use the survey just fine on his personal phone, in the exact same locations where she has had a problem.  It used to work fine for her before she got this phone from the organization.

The problem involves two survey questions that both pull data from a service via its REST URL.  I used a custom JS function and included the REST URL in the Excel that the survey is derived from (created with Survey123 Connect).  The JS function pulls data from fields in the REST service and populates the survey questions with that data.

The staff member's problem is that the survey is failing to pull data from this service.  Those questions just remain blank.  Her phone is using location just fine; the survey captures her correct location.  And this is not just about one location; the problem happens all the time for her.

I suspect that the problem is with her phone, maybe the security settings the organization configured on her phone, since things work fine on people's personal phones.  I asked her to go to the REST endpoint on her phone's browser, and she was able to view that page, but she said she had to hit "sync" first.  I am waiting on more details about this from her, but I wanted to post here and see if anyone happened to have some answers or guidance!

thank you!!

0 Kudos
1 Solution

Accepted Solutions
AllenDailey1
Occasional Contributor III

I have solved my problem.  For anyone who may be curious, here is the solution.  It's very simple - I had to update Survey123 Connect to the newest version and then republish the survey.  Then, survey users had to DELETE and download the survey again; simply refreshing the survey without deleting it was not effective.  

What happened was that we found out at the 2020 UC that in version 3.10 of S123, the "extensions" folder had to be named "scripts." We have a custom javascript function in this folder for this survey.  So a few months ago, we changed the folder name and republished the survey.  We had users refresh the survey (rather than fully deleting it and redownloading it).  But we did not notice that we were using version 3.5 of Survey123 Connect.  (On that note, I have posted and commented in a couple of "Ideas" in the Esri Community to have the app actually give you some indication that a new version is available!!!  That would have prevented this whole big ordeal that took several staff members multiple weeks to figure out.)

So, version 3.5 of Survey123 Connect did not publish our scripts folder.  Anyone who newly downloaded the survey after that date did not get the scripts folder, or actually any of the other changes we made to the survey.  That is why this one user had the problem - she was the only one to download the survey (rather than refresh an existing survey) during this time.  Actually, there was also another user who also newly downloaded the survey, and he had the same problem, but he never told us about it, so we didn't know about that until after a ton of digging.  

The other users, who previously had the survey and merely refreshed it after we did our survey edits, actually retained the extensions folder with the javascript file, so that file continued to work for them, weirdly.  

So our solution was to update Survey123 Connect, republish the survey, and ask survey users to DELETE and redownload the survey.

View solution in original post

4 Replies
JamesTedrick
Esri Esteemed Contributor

Hi @AllenDailey1 ,

Thanks for the feedback.  As you say, it sounds like a device-specific issue.  I'm curious about the need to 'hit "sync" first' - did that appear as a pop-up or on the web page?  

0 Kudos
AllenDailey1
Occasional Contributor III

Thanks, @JamesTedrick !  Unfortunately I don't know yet.  I know that would probably be a key detail.  I haven't heard back from the staff member about that yet.

0 Kudos
AllenDailey1
Occasional Contributor III

Thanks, @JamesTedrick !  Unfortunately I don't know yet.  I know that would probably be a key detail.  I haven't heard back from the staff member about that yet.

0 Kudos
AllenDailey1
Occasional Contributor III

I have solved my problem.  For anyone who may be curious, here is the solution.  It's very simple - I had to update Survey123 Connect to the newest version and then republish the survey.  Then, survey users had to DELETE and download the survey again; simply refreshing the survey without deleting it was not effective.  

What happened was that we found out at the 2020 UC that in version 3.10 of S123, the "extensions" folder had to be named "scripts." We have a custom javascript function in this folder for this survey.  So a few months ago, we changed the folder name and republished the survey.  We had users refresh the survey (rather than fully deleting it and redownloading it).  But we did not notice that we were using version 3.5 of Survey123 Connect.  (On that note, I have posted and commented in a couple of "Ideas" in the Esri Community to have the app actually give you some indication that a new version is available!!!  That would have prevented this whole big ordeal that took several staff members multiple weeks to figure out.)

So, version 3.5 of Survey123 Connect did not publish our scripts folder.  Anyone who newly downloaded the survey after that date did not get the scripts folder, or actually any of the other changes we made to the survey.  That is why this one user had the problem - she was the only one to download the survey (rather than refresh an existing survey) during this time.  Actually, there was also another user who also newly downloaded the survey, and he had the same problem, but he never told us about it, so we didn't know about that until after a ton of digging.  

The other users, who previously had the survey and merely refreshed it after we did our survey edits, actually retained the extensions folder with the javascript file, so that file continued to work for them, weirdly.  

So our solution was to update Survey123 Connect, republish the survey, and ask survey users to DELETE and redownload the survey.