Select to view content in your preferred language

Field Maps -> Survey123 Auto Populating Survey Questions: Potential Bug?

2176
5
01-13-2022 09:06 AM
Rice_GIS
Occasional Contributor

I am working with a feature layer, a related table, and a survey built from S123 Connect that, when submitted, adds a record to the related table. The feature layer is a point layer with a variety of information, while the table is related "one-to-many" to the "Name" field in both the feature and the table. The "Name" field is my feature's unique ID.

The purpose of this workflow is to allow field personnel to navigate to a point using field maps, and then click the point which will present the user with a custom pop up that has a link to survey123 mobile, with certain survey questions auto-populated based on the information of the selected point. I used the guidance in this article to set up this workflow: 

https://support.esri.com/en/technical-article/000021198 

I configured my feature pop-up to use the following link to direct the user to survey 123 mobile. 

arcgis-survey123://?itemID=3ac76ef7297d406ba833f37581ce7b3f&field:tract_name={Tract}&field:Name={Name}&field:habitat_type={HabitatGAP}

The Pop-Up is as follows: 

Rice_GIS_1-1642027826697.jpeg

But.... When I click "HERE" to link to the survey, the Survey looks as follows. 

Rice_GIS_2-1642027882947.jpeg

You can see how the Tract name after "Posey" is cut off and then no additional auto-populated information is available in the survey (Missing Point ID and GAP Habitat Majority-autofilled questions). However, it was only 2 points exhibiting this type behavior. All other habitat point surveys that were opened would show the auto-populated information: the tract name, point ID and GAP Habitat Majority when opened in S123.

I deliberated on this issue until I tried removing the apostrophe from the tract name. Consequently, the survey/field map work flow worked as it should, at the compromise that the tract name is no longer reflected correctly in the pop-up or in the related records. My big question- Is there a work around for this issue? Has anyone else ran into this? Clearly apostrophe's don't have a place in this work flow so is there any way this is a bug? I'd like to reiterate the point that the rest of the workflow works with no issues, for the exception of the two points that occur specifically on this Forever Wild Tract.

When I change the tract name of the feature to "Poseys" instead of "Posey's", the form is autopopulated with no issues. Note: Habitat majority is different in this screenshot but it is still a point that occurs on the same tract with the tract name in question.

Rice_GIS_0-1642092805785.jpeg

 I hope this makes any sense and will be happy to answer any questions anyone might have.

 

 

 

 

5 Replies
ZacharySutherby
Esri Regular Contributor

Hello @Rice_GIS

It is recommended to encode URL parameters. Encoding replaces invalid characters with the percent sign followed by their hex equivalent. Please see , https://doc.arcgis.com/en/survey123/reference/integratewithotherapps.htm#ESRI_SECTION1_7E0A66ACA8504... for more information

Thank you,
Zach
0 Kudos
Rice_GIS
Occasional Contributor

Good morning Zach,

Thanks for your reply.

I changed my link to now :

arcgis-survey123://?itemID=3ac76ef7297d406ba833f37581ce7b3f&encodeURLParams=true&field:tract_name={Tract}&field:Name={Name}&field:habitat_type={HabitatGAP} 

I got the pass through to work once I included encoded values in my feature layer as you can see in this picture.

Rice_GIS_0-1642177445168.png

While now the survey opens with no issues and looks as it should, I'm running into an issue where my pop up reflects the encoded value of the layer.

Rice_GIS_1-1642177543635.png

When I click the link to open survey, everything appears fine. 

Rice_GIS_2-1642177702779.jpeg

My big question now is, how can I code my pop-up to replace that hex code with the actual apostrophe? I'd like to avoid going as far as creating a whole new tract_name field as an alias field for my pop-up. Is there a work around to avoid doing this?

 

0 Kudos
MJBiazar
Esri Contributor

Hi @Rice_GIS ,

You can keep the apostrophes in the actual attribute values and use an Arcade expression to encode the values from that field to replace  " ' " with "%27" to include the encoded values in the URL instead of the actual values that contain apostrophes. 

 

Original URLs:

Arcade expression:

Updated URLs (attribute values encoded using an expression):

 

If you have multiple fields containing values with apostrophes that you need to pass as URL parameters to Survey123, you need to add a expression for each field.

If you are using the custom URL scheme only to launch Survey123 from Map Viewer, you cannot use this workflow since it will not give you the expected results. Map Viewer automatically encodes URLs so it replaces % in %27 (from the Arcade expression results) with "%25". As a result, it does not pass the expected values to the questions (e.g. "Amelia%27s French Bakery").

This workflow must be used only if the custom URL scheme is being utilized in mobile apps like Field Maps where the app reads the encoded values and passed the correct values to the survey form as expected (e.g. "Amelia's French Bakery").

 

Best,

MJ

0 Kudos
JeremyMiller
New Contributor

Where do you add the above Arcade "Replace" expression that you call in the URL? 

Thanks

0 Kudos
MJBiazar
Esri Contributor

Hi @JeremyMiller ,

 

One way to do this is to use an Arcade expression to encode the attributes that you want to pass as parameter in your custom URL and use it in your pop up. Below is an example:

 

1. From the pop up section, open Attribute expressions

1.jpg

 

2. Add an expression to replace any characters in your attributes that need to be encoded. For example, use an expression like below to replace ' with %27:

Replace($feature.question_name, "'", "%27")

2.jpg

 
 
3. Note the expression id, in this case: {expression/exp0}
 
3.jpg
 
 
4. Add a Text element to your pop up
 
 

4.jpg

 

5. Replace the field name with your expression id in the hyperlink to open your survey form and pass the encoded attributes. In the example below both URLs are included for comparison. First URL uses the actual values from the field and second URL uses the encoded values. 

5.jpg

6. Now, when the survey form is launched via the second URL in Field Maps app on a mobile device, attribute values are passed to the survey question as expected. Notice that when the first link is used, the attribute value is truncated after '. 
 
6.jpg
 
 
7. As I mentioned in my previous post above, this only works in field apps. For example, if you use the same link to launch your survey form in browser from Map Viewer, the first URL with actual values shows existing values as expected but the second URL shows the encoded values as a string.

 

7.jpg

 

Best,

MJ

0 Kudos