When passing a URL through Arcade Pop-up editor "&" gets "amp;" added

734
5
10-03-2019 11:49 AM
Highlighted
New Contributor

I'm configuring a basic pop-up within a Web Map using Arcade expressions.  For one of them I build a URL from an intersecting layer which is passed through to an image to be clicked.  When I test the expression the result is what is expected.  However, when I click on the image to which the expression is attached the URL is returned with "amp;" added directly after the "&" which breaks the link. 

And test results:

Actual passed URL:

http://recording.whatcomcounty.us/Image/DocumentImage?year=1889&itemId=5979

I've tried UrlEncode() on both the full string as well as just the & and while it does encode the URL does not work.  I've also tried encapsulating in text() but the & still gets converted at some point.

5 Replies
Highlighted
Esri Esteemed Contributor

Hi jmontroy ,

I'm trying to replicate the problem, but I am not able to. No need to encode or use Text to get the correct URL. I'm using this code to test:

var link = "1889x5979";
var url = "http://recording.whatcomcounty.us/Image/DocumentImage?year=" + Mid(link, 0, 4) + "&itemId=" + mid(link, 5);
return url;

And the result does not include any & 

Are you using the custom HTML pop-up?

Reply
0 Kudos
Highlighted
New Contributor

Xander Bakker‌, It does work as a link within the Pop-up Configuration dialogue, but if you try the same thing with the url attached to an image it does the 'amp;' thing.  My current work-around is to construct the URL string in the Image Link box using a expression for each of the parameters:

://recording.whatcomcounty.us/Image/DocumentImage?year={expression/expr0}&itemId={expression/expr2}

See if it does the same for you...

Thx

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi josh montroy ,

I see what you mean. I tried a couple of things. Creating an expression that returns the image URL and used that as URL and link. As you described the & is replaced & and makes the url invalid. Also using the expression that you mention at the end:

http://recording.whatcomcounty.us/Image/DocumentImage?year={expression/expr0}&itemId={expression/exp... does not seem to work.

The link however does work... Let me try something else and see if there is a hack to solve this. 

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi josh montroy ,

I think this might be a little more complex than I imagined even if the & would not be replaced. When I look at the "image" I notice that it is a pdf, or the page is using a plugin to convert the query to a pdf document:

<embed id="plugin" type="application/x-google-chrome-pdf" src="http://recording.whatcomcounty.us/Image/DocumentImage?year=1889&amp;itemId=5979" ... 

I don't think this will work. Maybe you could use this in a custom html pop-up, but it is likely that the embed code will be rejected for security reasons. 

Reply
0 Kudos
Highlighted
Esri Contributor

BUG-000126359 has been submitted to Esri Development for this issue. The issue is reproducible whenever an image link redirects to a URL based on the return of an Arcade expression. Thank you for your contribution to the Esri Community!