I built some basic arcade expressions to plug into a field maps form to capture some attributes for point features our folks on the field are collecting. Some of these work, others I have been getting an error that the form "Failed to calculate."
Here is one of the following expressions to populate City Data for said point features:
var cities = FeatureSetByName($map, 'Political Boundaries', ['Name ID'])
var intersectCities = First(Intersects(feature, cities))
if (!IsEmpty(intersectCities)) {
return intersectCities['Name ID']
}else {
return null
}
However, upon testing this expression in field maps it appears to fail to calculate the expression:
I am unsure what the issue is precisely, I have similar expressions built for Tile Grid which works but it seems to be having issues with Cities and even Districts. Has anyone come across this issue?
Solved! Go to Solution.
Figured it out, I was using the field alias as opposed to the field name. Only reason why the attributes for the tiles worked was because the field name and field alias' were identical.
Thank you all for your feedback!
Hey @alex_parij
In your code, could it be that you're referencing the feature without the $?
var cities = FeatureSetByName($map, 'Political Boundaries', ['Name ID']);
var intersectCities = First(Intersects($feature, cities));
if (!IsEmpty(intersectCities)) {
return intersectCities['Name ID'];
} else {
return null;
}
Cody
It looks pretty straightforward, but I imagine that var intersectCities = First(Intersects(feature, cities)) is causing some problems for not having the $?
var intersectCities = First(Intersects($feature, cities))
Unfortunately I am still having the same issue. Here is the code for Districts:
Do you get an error message when you hit run in the Arcade expression builder?
I do not, everything seems kosher in the expression builder window:
In theory this should do nothing, but can you split out your First and your Intersects steps into two separate variables? Once in a while for no good reason this seems to help me.
Figured it out, I was using the field alias as opposed to the field name. Only reason why the attributes for the tiles worked was because the field name and field alias' were identical.
Thank you all for your feedback!