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?
Hi Chris Sands ,
I hate to tell you but unfortunately, an Arcade expression does not have any knowledge of the existence of other Arcade expressions. It would be a great feature to have! You will have to copy the content of the other Arcade expression and paste it into the one you are writing.
Thank you. That was not the answer I wanted, but it means I can stop spending time doing something that won't work.
These popup expressions are associated with the county parcel layer for which they are written. Is it possible to associate the expressions with the group layer that contains all the county parcel layers rather than the individual county parcel layers, so that each of the parcel layers (all with the same fields) can reference the existing expressions?
Or do I need to copy my expressions for each county parcel layer?
Hi Chris Sands ,
I guess it would be less problematic if you would have a single layer for all the counties and only have to apply the expression once. If the county layer all cover a different area, I'm afraid you will have to apply the expression to each layer. In case you have several layers that overlap you could apply a single expression that drills through the different layer and present the information in a single pop-up, but I guess that will not be the case for you.
Thanks for the answer. Again, not what I was hoping for but good to know.