Having problems getting a spatial join to work on a Field Maps calculated expression

499
3
08-17-2022 08:41 AM
ChipMorgan
New Contributor II

Hi,

   I'd like to auto-fill the county for the current location when I create a feature in AGOL (New) Map Viewer, following the general approach laid out here: https://community.esri.com/t5/arcgis-online-blog/overlapping-features-in-pop-ups-quick-introduction/...

   Here's what I have:

var Counties=Intersects(FeatureSetByName($map,"USA Counties (Generalized)"),$feature)
for (var county in Counties){
    return county.NAME
}

   In the Arcade editor inside Field Maps editor, the "Test" button confirms the proper syntax and returns the correct (single) value. However, when I create a feature in the AGOL (New) Map Viewer, nothing shows up in this field.

   I've isolated that the Intersects (or FeatureSetByName) function is causing issues, though I'm not sure what the problem is. The following troubleshooting example returns nothing in AGOL (it should always return "test"):

var Counties=Intersects(FeatureSetByName($map,"USA Counties (Generalized)"),$feature)
return "test"

    I did confirm that the following code works, just as a sanity test:

return "test"

   Oh, and I did try the FeatureSetByID function instead of FeatureSetByName, with similar results.

   Any help would be greatly appreciated.

Tags (3)
0 Kudos
3 Replies
ChipMorgan
New Contributor II

Curiously, that same logic actually works as an attribute expression in a pop-up in the same map. Odd.

0 Kudos
ChipMorgan
New Contributor II

Just stumbled across the issue. I had been using the form editor in Field Maps. When I opened the Forms menu on Map Viewer (which does show the same forms as in Field Maps), I got the following warning:

Expression compatibility
Calculated expressions that use Feature Sets are not supported in Map Viewer.
 
 
Dangit.
0 Kudos
ChipMorgan
New Contributor II

Here's what's weird. Despite that warning message (see my preceding post), the Arcade editor in Map Viewer Forms supports Feature Set functions. When I click the Test button, it works correctly. Furthermore, you can browse the functions on the right pane of the editor and select Feature Set functions for the various map layers.

0 Kudos