Creating link with hyperlink in popup field based on a condition

764
1
Jump to solution
12-03-2022 08:07 AM
TimHayes3
Occasional Contributor

I have a point feature class named Shelters. There is a field named "SHELTERPREPLAN" in the default pop up. This field has Yes and No values. 

I am learning Arcade. I need to make a conditional popup where if SHELTERPREPLAN = Yes then the "Yes" would be a link to a hyperlink; If SHELTERPREPLAN = No, then no action would be taken. 

I know that I need to use href somewhere maybe like this: 

<a href="myurl">Yes</a>

Here is the expression I have created, maybe someone out there can give me a little push in the right direction:

IIF($feature["SHELTERPREPLAN"]=="Yes", "myurl", "")

The above bit of code outputs the url in the SHELTERPREPLAN field. But what is the best way to add the href so the Yes becomes a link to the url?

I am using Map Viewer Classic or can use Map Viewer if this helps. 

0 Kudos
1 Solution

Accepted Solutions
DanielMiranda2
Occasional Contributor

The code below will return the value in a field called myURL, with the display text as Yes. It will only show this if Shelter Plan is equal to Yes. Any other value will result in a blank.

 

I did this in Map Viewer, mainly because the Arcade editor is much easier to work with since it provides suggestions.

if ($feature.SHELTERPLAN == "Yes"){
  return { 
	  type : 'text', 
	  text : '<a href=' + $feature.myURL + '>Yes</a>' //this property supports html tags 
  }  
}

 

View solution in original post

0 Kudos
1 Reply
DanielMiranda2
Occasional Contributor

The code below will return the value in a field called myURL, with the display text as Yes. It will only show this if Shelter Plan is equal to Yes. Any other value will result in a blank.

 

I did this in Map Viewer, mainly because the Arcade editor is much easier to work with since it provides suggestions.

if ($feature.SHELTERPLAN == "Yes"){
  return { 
	  type : 'text', 
	  text : '<a href=' + $feature.myURL + '>Yes</a>' //this property supports html tags 
  }  
}

 

0 Kudos