Select to view content in your preferred language

URL not link shows up in pop up field using Arcade

2406
7
Jump to solution
12-12-2022 10:53 AM
TimHayes3
Frequent Contributor

I am using Map Viewer. 

I need my pop up to show a link (not the actual url) when there is a "Yes" in the field. Here is what I have done so far, but it shows the actual url in the pop up field. What do I need to change to get it to show a link?

if ($feature.SHELTERPREPLAN == "Yes"){
  return {
    type : 'text',
    text : '<a href= "https://rtlt.preptoolkit.fema.gov/Public/Resource/ViewFile/9-508-1192?type=Pdf&s=Name&p=7" >Yes</a>' //this property supports html tags
  }  
}
 
 
Here is the result in the popup: 
ShelterPrePlan Popup.JPG
0 Kudos
1 Solution

Accepted Solutions
JoshuaSharp-Heward
Frequent Contributor

Hi Tim,

You can simply return the url as text without the HTML code you've got there and it will appear in the popup as a link with the default caption "View".

Alternatively what you could do is have an attribute expression that returns a text value of "Link to xx", and then add a "Text" section at the bottom of your popup referencing that expression, and add a hyperlink to the site you want to direct users to (not in the arcade expression or HTML, just using the default "add a link" part of the text editor). That way if the shelter pre-plan doesn't have a value the text/link won't appear. Hope that all makes sense, happy to elaborate if need be!

View solution in original post

7 Replies
JoshuaSharp-Heward
Frequent Contributor

Hi Tim,

You can simply return the url as text without the HTML code you've got there and it will appear in the popup as a link with the default caption "View".

Alternatively what you could do is have an attribute expression that returns a text value of "Link to xx", and then add a "Text" section at the bottom of your popup referencing that expression, and add a hyperlink to the site you want to direct users to (not in the arcade expression or HTML, just using the default "add a link" part of the text editor). That way if the shelter pre-plan doesn't have a value the text/link won't appear. Hope that all makes sense, happy to elaborate if need be!

TimHayes3
Frequent Contributor

Thanks, this gets me in the right direction. Super helpful!

I was able to cobble this together, can you assist me with figuring out how to add "Yes" instead of "View"?

I am almost there, I think. 

if ($feature.SHELTERPREPLAN == "Yes")
{return
else {return "No"}

 

0 Kudos
JoshuaSharp-Heward
Frequent Contributor

You could definitely accomplish that with the second part of my recommendation! Create two expressions, one that returns "No shelter plan" and one that return "Shelter plan completed" or something along those lines, then add both to a text box at the bottom and add the url that you want them to visit as a link for the "Shelter plan completed" arcade expression and no link for the "No shelter plan".

TimHayes3
Frequent Contributor

Your idea would work, but is there another way to change "View" to "Yes"?

0 Kudos
JoshuaSharp-Heward
Frequent Contributor

I don't believe so no, it's been a couple years since I tried to do what you're doing but I'm pretty sure I found it was impossible, unless you formatted the whole popup as HTML.

TimHayes3
Frequent Contributor

Yes, I heard same thing. I will stay with the "View" and "No". If my client insists on having "Yes" replace "View" then I guess I will need to format whole popup as HTML. Thank you for all your valuable assistance. 

0 Kudos
JoshuaSharp-Heward
Frequent Contributor

No worries, glad I could help out Tim!