Select to view content in your preferred language

Survey 123 Custom URL issue with special characters in field values

1138
5
Jump to solution
07-11-2023 02:53 PM
Labels (1)
brward
by
Occasional Contributor

I have a posted field maps map with a popup set up with the popular custom URL capability to auto open up a Survey and autofill survey questions with values from the original Feature Class from the Field Map app.

brward_0-1689112312616.png

Link shown in popup text: arcgis-survey123://?itemID=xxxxxx&field:Rel_GlobalID={GlobalID}&field:Project_Name={ProjectName}...ect

Survey is made through S123 Connect version3.15 and uses an existing enterprise feature service to edit a Related Table to track inspections on subdivisions in our city. My issue is that if the Project Name or any other fields have a special character such as # or & it will cut the rest of the value from the field it is pulling from. If i remove the special character from the attribute, the entire value pulls into the survey properly. This issue occurs only on tablets. Windows desktop it has no problem. Is it an issue with it pulling the attribute through a URL and # and & characters are not allowed through URL's?

0 Kudos
1 Solution

Accepted Solutions
brward
by
Occasional Contributor
I ended up creating an expression in my popup with the following code:
 
var urlsource ='arcgis-survey123://?itemID=';
var itemID = 'xyzxyz'; //itemID of the S123 form
var ProjectName = UrlEncode($feature.NAME);
var RelatedGlobalID = UrlEncode($feature.GlobalID);


var link = urlsource  + itemID + "&field:ParkName=" + ProjectName + "&field:RelatedGlobalID=" + RelatedGlobalID

return link
 
I am sure there is a more efficient way to convert each field with the URLEncode function, but doing each field at a time worked for me. Once the attribute expression is made, you create a url link with a text content in the popup that calls said expression.
 
brward_0-1751905432495.png

 

View solution in original post

0 Kudos
5 Replies
jcarlson
MVP Esteemed Contributor

There is a special Arcade function called URLEncode, which you can read about here: https://developers.arcgis.com/arcade/function-reference/text_functions/#urlencode

Use Arcade to generate the link, and you will have a properly-formatted URL in which the special characters are escaped.

- Josh Carlson
Kendall County GIS
brward
by
Occasional Contributor

I believe i see what you mean. I am trying to set up the arcade with syntax found online but i am not sure what i am doing wrong to set the dictionary for the params variable. I have in photo example below. I also need more that one field to auto populate, would i do that with just multiple 'field' objects in the dictionary?

brward_1-1689189125824.png

 

 

JamesTurner2
Regular Contributor

What was the solution for this? I am having the same issue with multiple fields that need to be encoded

0 Kudos
brward
by
Occasional Contributor
I ended up creating an expression in my popup with the following code:
 
var urlsource ='arcgis-survey123://?itemID=';
var itemID = 'xyzxyz'; //itemID of the S123 form
var ProjectName = UrlEncode($feature.NAME);
var RelatedGlobalID = UrlEncode($feature.GlobalID);


var link = urlsource  + itemID + "&field:ParkName=" + ProjectName + "&field:RelatedGlobalID=" + RelatedGlobalID

return link
 
I am sure there is a more efficient way to convert each field with the URLEncode function, but doing each field at a time worked for me. Once the attribute expression is made, you create a url link with a text content in the popup that calls said expression.
 
brward_0-1751905432495.png

 

0 Kudos
JamesTurner2
Regular Contributor

Thanks, It looks like our intern was able to crack the code on the URLEncode function, here's an example for other's to use in the future.

var urlsource ='arcgis-survey123://?https://gis.maine.gov/arcgisportal/?';
var params = {
  itemID:'0a9182aa703f4a28ac60c9b693768593',
  "field:inspection_type": 'in_progress',
  "field:project_name": $feature["project_name"],
  "field:sponsor": $feature.sponsor,
  "field:funding_source": 'RTP',
  "field:project_number": $feature["project_id"],
  "field:year_": $feature["year_funded"],
  "field:designed_trail_use": $feature["designed_trail_use"],
  "field:managed_trail_use": $feature["managed_trail_use"]
};
return urlsource  + UrlEncode(params);
0 Kudos