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;