Select to view content in your preferred language

Arcade field calculation table not found

230
3
12-20-2024 09:42 AM
Justin_CLT
Occasional Contributor

I'm trying to write an expression to calculate the elevation field of stormwater devices from the intersecting polygon from another layer in the same REST service. I have been able to calculate fields from intersecting features before, but for some reason it keeps giving me an error. If I use $datastore, I get table not found. If I use $map or $layer, I get object not found, even though the layer is loaded in the current map. The error is coming on the first assignment statement. What am I getting wrong?

 

// Retrieve the DEM polygons feature set
var demFeatures = FeatureSetByName($datastore, "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;

 

Tags (1)
0 Kudos
3 Replies
VanessaSimps
Frequent Contributor

I believe you have to include the owner as well as the feature. 

In this example, ESAGE is the owner of swSubbasins:

var subb = FeatureSetByName($datastore,"ESAGE.swSubbasin",["SUBBASIN"], true)

Give that a try and see if that helps.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

please post code using the insert code sample option

// Retrieve the DEM polygons feature set
var demFeatures = FeatureSetByName($datastore, "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;

 
0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Why is the 'Interescts($feature)' a string?  Dont think you need filter at all 

change to

var intersectingPolygons = Intersects(demFeatures, $feature);
0 Kudos