Select to view content in your preferred language

Arcade Expression to hyperlink based on if / else if

499
1
11-01-2023 11:15 AM
Labels (1)
Brian_McLeer
Frequent Contributor

Trying to hyperlink to a website (var URL below) if the cabinet status is Active, I would like to return "available, please click here to sign up for service" with the "click here" acting as a hyperlink. The code works below without, but when trying to link it is just showing the full HREF code. 

 

var intersectLayer = Intersects(FeatureSetByName($map, "HiLight Availability"), Buffer($feature, 0, 'feet'));
var zones = "";
var URL = "https://www.website.com";

if (Count(intersectLayer) > 0) {
   for (var f in intersectLayer) {
       if (f.CabinetStatus == 'Active') {
           zones = 'available';
           break;  // Exit the loop if an 'Active' status is found.
       } else if (f.CabinetStatus == 'Future') {
           zones = 'anticipated for future development';
           break;  // Exit the loop if a 'Future' status is found.
       } else if (f.CabinetStatus == 'Planned') {
           zones = 'planned';
           break;  // Exit the loop if a 'Planned' status is found.
       } else if (f.CabinetStatus == 'In Progress') {
           zones = 'in progress';
           break;  // Exit the loop if an 'In Progress' status is found.
       }
   }
} else {
   zones = 'not available at this address';
}

return lower(zones);

 

Brian
1 Reply
gis_KIWI4
Frequent Contributor

@Brian_McLeer - One way I have been able to do this by setting an attribute expression that is used with Text element in the pop-up. 

Step 1 - Setting the attribute expression. Workout your conditional statements and the respective URLs. 

gis_KIWI4_0-1699306377229.png


example - I have used the below condition in the URL Links expression.

if ($feature.Dorian_2019 == "YES")
{
  return "www.google.com"
}
else {
  return "www.youtube.com"
}


Step 2 - Add a text element to the pop-up. 
Insert the custom expression as a hyperlink. 

gis_KIWI4_1-1699306535348.png

gis_KIWI4_2-1699306565656.png

 

Results - 

gis_KIWI4_3-1699306620306.png

gis_KIWI4_4-1699306635899.png

 

Hope this helps 🙂 

 

 

 

 

0 Kudos