I am trying to get a field value from a feature using Arcade and pass it to a label for a chart in a popup.
I create the expression outside the JavaScript to get the field value:
<script type="text/arcgis-arcade" id="field-name">
var label = $feature.Field2;
return {label};
</script>
Then I reference the script:
var arcadeFields = document.getElementById("field-name").text;
Finally, I use the variable in the label property of the popupTemplate:
popupTemplate: {
title: "Layer1",
fieldInfos: [{
fieldName: "Field18",
label: "Field 18 label"
},
{
fieldName: "Field25",
label: arcadeFields
}
],
It is almost working as intended, only the label for the chart shows the Arcade expression shown below, but not the actual field value.
How do I get the Arcade script to return the field value and not the expression?
Here's a codepen of it in action if you click on one of the parcels with a value.
Thanks in advance.