Any help with this greatly appreciated.
I am trying to run a script using the Calculate Field tool (a script by @JohannesLindner ).
// load the polygons
var polygons = FeaturesetByName($datastore, Counties)
// get the polygon that intersects the current point
var i_polygon = First(Intersects(polygons, $feature))
// return a default value if no polygon is intersecting
if(i_polygon == null) { return null }
// return the name of the Polygon
return i_polygon.COUNTY
This has previously worked for me but when I try it with a different polygon layer (Counties) I get an error code: ERROR 002717: Invalid Arcade expression, Arcade error: Object not found counties, Script line: 2
The polygon layer is in a local folder and is definitely in the Contents.
Thanks.
Since Counties is a name, it needs to be in quotes.
var polygons = FeaturesetByName($datastore, 'Counties')
Thanks for the reply. Regardless of whether I use Counties, 'Counties', or "Counties" I still get the same error message (ERROR 002717).
I've also tried changing the polygon layer name to CountyBoundary and still get the same error message.
So, referencing the $datastore assumes the other layer is coming from the same data source. Are these layers published in the same service, or if offline, coming from the same database?
Try referencing $map instead of the datastore.
Thanks Josh. Layers are all held locally and coming from the same folder.
When I reference $map I get the following error message:
ERROR 002717: Invalid Arcade expression, Arcade error: Object not found $map, Script line: 2
There have been no updates to the laptop or ArcPro since it previously worked.
Ah yeah, Pro doesn't like the $map object. That's for web maps only, I guess.
No updates to the software, but what about the data? I can't imagine the expression working at all with shapefiles in a folder. Were they downloaded from a web service, or copied from a database?
Weirdly enough it worked previously with shapefile data from a local folder.
Point data was exported from a SQL database. Polygon data was downloaded from a webservice. Both have been worked on locally prior to running the script.
Is it a featureclass in a file geodatabase? or a shapefile in a folder?
It's a shapefile in a folder.
To add to the initial query... An mxd in which the script previously worked is now throwing the same error.