I am in an ArcGIS Enterprise 11.5 Map Viewer. The map contains a Parcels feature layer and an Elementary School Boundaries layer, among others.
I have configured the parcel layer with a pop-up Arcade expression to grab information about the elementary school whose boundary includes the clicked parcel. The elementary school attribute table has a NAME field and URL field. I would like to later show the user the NAME of the school, with a hyperlink that takes the user to the school's URL.
This is the basis for the code I'm using:
var layer_name = "Elementary School Boundaries";
var field_names = ["Name", "URL"];
var layer = FeatureSetByName($map, layer_name, field_names, false);
var pinhole = Intersects($feature, layer);
var value = Null;
if (!IsEmpty(pinhole))
value = First(pinhole);
return value;
This code returns a Feature, but I've also tried returning a Dictionary, as well as a complete HTML anchor string, but nothing works. Anyway, the resulting expression is given the value {expression\expr7}
The popup HTML looks a little like this, but I've tried a number of variations:
<ul>
<li>
<span style="color:#000000;">Elementary: </span><span style="color:#0088ff;"><a href="{expression/expr7?.URL}" target="_blank">{expression/expr7?.NAME}</a></span>
</li>
</ul>
The anchor tag gets erased by the formatter (meaning, when I click the <> button to get out of code mode) and no text is displayed in the 0088ff color. If my Arcade code is modified to return a full anchor tag such as:
<a href="https://someschool.org" target="_blank">Some Elementary School</a>
I then modify the HTML to look like this:
<ul>
<li>
<span style="color:#000000;">Elementary: </span><span style="color:#0088ff;">{expression/expr7?.NAME}</span>
</li>
</ul>Then what happens is that the anchor tag, URL, and school name appear as-is to the user in the pop-up.
A work-around for this problem is to create TWO expressions, both of which mainly have the same code except one expression grabs the NAME and the other grabs the URL. I've gotten that to work. But that means two spatial intersections when I only want one. Please note that I want to do this to many other layers in the map, and I don't want ArcGIS to do twice the work. I simply want to fetch two fields from each layer and to use those two fields to construct hyperlinks.