I am using Arcade to customize the popup in a WAB Web Map.
I am using parcel data in Florida and I have two fields in the data that use the same set of numeric county codes (CO_NO and CONO_PRV_H). I have a function to lookup the numeric value and return the county name. In {expression/expr12} I have function lookupCountyCode(countyCode){... return countyName}.
I would like to be able to call that function from another expression or from the popup configuration, but I have not found any examples of how to do that. The obvious syntax would be {expression/expr12}.lookupCountyCode($feature["CO_NO"]) and then where I need the other value {expression/expr12}.lookupCountyCode($feature["CONO_PRV_H"]) but that doesn't do what I want.
I see "County Code Lookup" (the name I gave my expression) in the Existing functions in the Arcade interface. If I click it, it adds a copy of my code to the current expression. I don't want another copy of the code to maintain. I want a way to call the function from outside the expression and I want to pass in the field as a value. I can't figure out what the syntax is.
I even added a script tag to the HTML view of the popup Configuration with the lookupCountyCode function in it.
<script type="text/arcade">function lookupCountyCode(countyCode){...return countyName}</script>
But when I saved the map, the script tag and function vanished.
How can I call this function from outside the expression and pass it a data field as a parameter? Or is this a limitation of Arcade?
Then, once I have resolved this for the first county parcel layer, how can I apply it to all 67 county parcel layers without having to re-create all of my expressions repeatedly?