Can I limit characters passed through a url parameter to survey123?

578
4
Jump to solution
04-11-2022 09:08 AM
ChelseaTabor
New Contributor III

I'm passing an address from a webmap popup to a survey via url parameter, but there ends up being spaces added after the street name.  After some investigation I found that the address field length is 20, and the survey question ends up with the street name + number of spaces equal to 20.  

Here's the url parameter:

&field:address_webmap={StreetNumber} {ServiceStreet}, {Zip}

ChelseaTabor_0-1649693124879.png

So "RED MILE RD         " is passed from the url parameter to the survey rather than "RED MILE RD" with no spaces.  I get the same results if I concatenate the address fields within the form. 

How do I trim these spaces off the end and only pass the necessary number of characters?

 

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

I have not done that before, but I would try first populating the link in the popup using an Arcade expression. the Trim  function should be able to help.

View solution in original post

4 Replies
IsmaelChivite
Esri Notable Contributor

I have not done that before, but I would try first populating the link in the popup using an Arcade expression. the Trim  function should be able to help.

ChelseaTabor
New Contributor III

I initially tried using an arcade expression, but the variable string passed to the survey rather than the value in that field.

Here's the expression for the url:

var survey = "arcgis-survey123://?itemID=7af329de75f2403996b66db3e941b252"
var assetid = "&field:assetid={wServiceConnection.ACCOUNTID}"
var assettype = "&field:assettype=Service"
var leaktype = "&field:leaktype=service"
var meteraddr = "&field:meteraddr={HARRIS.dbo.vwNSAccount.StreetNumber} {HARRIS.dbo.vwNSAccount.ServiceStreet}"
var metercity = "&field:metercity={HARRIS.dbo.vwNSAccount.ServiceCity}"
var meterzip = "&field:meterzip={HARRIS.dbo.vwNSAccount.Zip}"
var lat = "&field:lat={wServiceConnection.LAT}"
var lon = "&field:lon={wServiceConnection.LONGI}"
var address_webmap = "&field:address_webmap={HARRIS.dbo.vwNSAccount.StreetNumber} {HARRIS.dbo.vwNSAccount.ServiceStreet}, {HARRIS.dbo.vwNSAccount.Zip}"


var url =
survey
+ assetid
+ assettype
+ leaktype
+ meteraddr
+ metercity
+ meterzip
+ lat
+ lon
+ address_webmap

return url

 

When I test this expression I get the following url, which works if I copy/paste it into popup link, but not if I add it as an expression.

arcgis-survey123://?itemID=7af329de75f2403996b66db3e941b252&field:assetid={wServiceConnection.ACCOUNTID}&field:assettype=Service&field:leaktype=service&field:meteraddr={HARRIS.dbo.vwNSAccount.StreetNumber} {HARRIS.dbo.vwNSAccount.ServiceStreet}&field:metercity={HARRIS.dbo.vwNSAccount.ServiceCity}&field:meterzip={HARRIS.dbo.vwNSAccount.Zip}&field:lat={wServiceConnection.LAT}&field:lon={wServiceConnection.LONGI}&field:address_webmap={HARRIS.dbo.vwNSAccount.StreetNumber} {HARRIS.dbo.vwNSAccount.ServiceStreet}, {HARRIS.dbo.vwNSAccount.Zip}

0 Kudos
AlexanderLynch2
New Contributor III

var survey = "arcgis-survey123://?itemID=7af329de75f2403996b66db3e941b252"
var assetid = "&field:assetid={wServiceConnection.ACCOUNTID}"
var assettype = "&field:assettype=Service"
var leaktype = "&field:leaktype=service"
var meteraddr = "&field:meteraddr={HARRIS.dbo.vwNSAccount.StreetNumber} {HARRIS.dbo.vwNSAccount.ServiceStreet}"
var metercity = "&field:metercity={HARRIS.dbo.vwNSAccount.ServiceCity}"
var meterzip = "&field:meterzip={HARRIS.dbo.vwNSAccount.Zip}"
var lat = "&field:lat={wServiceConnection.LAT}"
var lon = "&field:lon={wServiceConnection.LONGI}"
var address_webmap = "&field:address_webmap={HARRIS.dbo.vwNSAccount.StreetNumber} {HARRIS.dbo.vwNSAccount.ServiceStreet}, {HARRIS.dbo.vwNSAccount.Zip}"


var url =
survey
+ assetid
+ assettype
+ leaktype
+ meteraddr
+ metercity
+ meterzip
+ lat
+ lon
+ address_webmap.trim()

return url

 

personally, you should use CR/NL after operator and not before.

0 Kudos
ChelseaTabor
New Contributor III

Thank you!

I was missing the '$feature[]' for each field instead of curly braces and added the Trim() and Proper() functions to the address fields.

var survey = "arcgis-survey123://?itemID=7af329de75f2403996b66db3e941b252"
var assetid = "&field:assetid=" + $feature["wServiceConnection.ACCOUNTID"]
var assettype = "&field:assettype=Service"
var leaktype = "&field:leaktype=service"
var meteraddr = "&field:meteraddr=" + $feature["HARRIS.dbo.vwNSAccount.StreetNumber"] + " " + Proper(Trim($feature["HARRIS.dbo.vwNSAccount.ServiceStreet"]), 'everyword')
var metercity = "&field:metercity=" + Proper(Trim($feature["HARRIS.dbo.vwNSAccount.ServiceCity"]), 'everyword')
var meterzip = "&field:meterzip=" + Trim($feature["HARRIS.dbo.vwNSAccount.Zip"])
var lat = "&field:lat=" + $feature["wServiceConnection.LAT"]
var lon = "&field:lon=" + $feature["wServiceConnection.LONGI"]


var url =
survey +
assetid +
assettype +
leaktype +
meteraddr +
metercity +
meterzip +
lat +
lon


return url