I tried to count the number of points (call it incident layer) when I click on a polygon layer (call it administrative_bound layer) and display it on the pop-up.
I have 2 layers, separate map service layers. I am using Arcgis enterprise Standard bought on 2023 (version 11.0 I think).
I have read here and there, none worked:
https://support.esri.com/en-us/knowledge-base/how-to-display-a-count-of-different-point-features-in-...
https://www.reddit.com/r/gis/comments/1c7b0ah/featuresetbyname/
https://developers.arcgis.com/arcade/function-reference/featureset_functions/#filter
https://support.vertigis.com/hc/de/community/posts/11498023882642-How-to-use-Arcade-Expressions
For the start, I cant even declare a variable, for example:
var Point1 = FeaturesetByName($map, 'incident')
The error is: Execution Error:Runtime Error: Identifier Not Found. $map
I also try: FeatureSetById.. does not work too ! The same error comes up.
Please help.. thanks
And you're writing this expression in a web map? $map should be available to you there. Or are you writing it in ArcGIS Pro? Sometimes the $map object doesn't work in that context.
What about FeatureSetByPortalItem? That function doesn't rely on anything, and should work across contexts.
var incidents = FeatureSetByPortalItem(
Portal('your portal url'),
'itemid of your incidents layer',
0,
['objectid'],
true
)
var xs_incidents = Intersects($feature, incidents)
return Count(xs_incidents)
I make a fundamental mistake. The most important thing is TO PUBLISH THE MAP SERVICE AS FEATURE SERVICE (you know, the map service that can be edited online..). Never know about this...
First of all, on ArcGIS Pro, choose "Copy all data: Feature" when sharing / publish the map. Here is the option to publish as Feature Service :
After this, then you will see some options on the Attribute Expression when you create Web App (the Classic one). These options did not appear before... See picture below:
I read on another post regarding the same problem in this Community Forum (can't find it.. some guy named "xxamrstrong) that you have to publish it as individual map (feature) service too, to be able to activate the calling to the Identifier...
Before, I also tried the FeatureSetByPortalItem. It worked.. but kinda messy (too long codes).
Thanks @jcarlson for helping me out