I am using an arcade script to calculate and format a popup in a map which calculates the area of a department across various regions (on the same level, facility, site, district) and also lists the other facilities that have units with that same department. So when you select a unit, it gives information on that unit, including the department it is allocated to, and then gives some square footage stats related to that department. The pop up works great when looking at it in Pro and in a web map, however when I use that web map in ExB, it does not always calculate the area correctly or list all the other related facilities. Because it works as expected in Pro and web maps (and for some units while in ExB) I'm fairly confident my script is fine, but I'm wondering if there is some issue with how Arcade works inside ExB? I tried to use WebApp Builder just to see, and the pop ups do not render anything at all. I have gotten the same results across multiple devices, in Chrome and Edge but I have not tried other browsers yet.
Here is how a pop up renders (correctly) in a Web Map:
And the same feature in ExB (incorrect):
Another example of a different error, in Web Map (correct):
And the same feature in ExB (incorrect):
If anyone has any ideas on what could be happening, I'd love to hear it.
Solved! Go to Solution.
I was able to figure it out.
I switched out FeatureSetByName($map, "LayerName", ["fields"]) to FeatureSetByName($datastore, "LayerName", ["fields"]).
Something about how the widgets in ExB will strip down the data if only using $map (I assume for quicker responses) and is meant to used more for things directly related to the individual map object, but $datastore access the data directly and does not strip away anything.
You could try adding the following to your script:
Expects($feature, '*')
According to the help this "Requests all fields because the required fields may be based on unknown information"
Basically it requests all data for the feature and make sure is available before performing calculations.
It makes the popups slower but has helped me solve issues with my arcade scripts in the past.
I really thought that was going to be it, but unfortunately it did not work. I appreciate the idea to try though, and it's good to know about that function.
@MollyE - This is weird. the Arcade should be set at the map level and ExB shouldn't really affect it.
The only other thing I can think of is spatial elements within arcade.
Are you using "touches" or "within" your arcade? I know the geometry is generalized sometimes depending on what scale you are at.
I am not, but I am using the Shape__Area field and we have our own gross_area field calculated from our CAD data, and it matches up pretty exactly so I will try using the gross_area field instead and see how that goes. I don't think the Shape__Area changes on the fly when the geo is generalized but it's worth a shot.
I was able to figure it out.
I switched out FeatureSetByName($map, "LayerName", ["fields"]) to FeatureSetByName($datastore, "LayerName", ["fields"]).
Something about how the widgets in ExB will strip down the data if only using $map (I assume for quicker responses) and is meant to used more for things directly related to the individual map object, but $datastore access the data directly and does not strip away anything.
Awesome work! Learnt something new today.