I'm trying to write a field calculation expression in Arcade that will populate a value in the field of a point feature using a value from the intersecting polygon from another feature class in the same map. The documentation I've seen shows to reference a layer in the same map using either $map or $layer. I've tried both of the lines below, but neither are working and give me an object not found error.
var dem = FeatureSetByName($map, “Elev_Polygons_2023”, “FieldName = ‘gridcode’”);
var dem = FeatureSetByName($layer, “Elev_Polygons_2023”, “FieldName = ‘gridcode’”);
Here is the full expression so far:
// Reference the current device feature
var device = $feature;
// Retrieve the DEM polygons feature set
var demFeatures = FeatureSetByName($layer, "Elev_Polygons_2023", ["gridcode"], true);
// Find the polygons that intersect with the current device
var intersectingPolygons = Filter(demFeatures, 'Intersects($feature)');
// Get the first intersecting polygon
var intersectingPolygon = First(intersectingPolygons);
// Extract the gridcode value if an intersecting polygon exists
var elevation = intersectingPolygon["gridcode"];
// Return the elevation value
return elevation;
Where are you trying to use this expression? Referencing other layers with Arcade functions a little differently in ArcGIS Pro compared to the web.
If the DEM polygons are a published service, I'd suggest using FeatureSetByPortalItem instead, as it will work regardless of whether the layer is present in the map, and works the same in Pro or the web.
I'm using it in a field calculation in Pro. The Elev_Polygons_2023 feature class is in a file geodatabase.
Any chance the layers are in the same geodatabase? You could try using $datastore in the FeatureSetByName, rather than $layer or $map.
They are not in the same geodatabase.