Select to view content in your preferred language

Failed to calculate expression.

119
7
Jump to solution
Monday
alex_parij
Emerging Contributor

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:

alex_parij_0-1726518463494.png

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?

0 Kudos
1 Solution

Accepted Solutions
alex_parij
Emerging Contributor

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!

View solution in original post

0 Kudos
7 Replies
CodyPatterson
Frequent Contributor

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

0 Kudos
ZachBodenner
MVP Regular Contributor

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))
0 Kudos
alex_parij
Emerging Contributor

Unfortunately I am still having the same issue. Here is the code for Districts:

var district = FeatureSetByName($map, 'District' , ['Name ID'])
var intersectDistrict = First(Intersects($feature, district))
if (!IsEmpty(intersectDistrict)) {
  return intersectDistrict['Name ID']
}else {
  return null
}
 
As far as I can tell, there should be no issue.
0 Kudos
ZachBodenner
MVP Regular Contributor

Do you get an error message when you hit run in the Arcade expression builder?

0 Kudos
alex_parij
Emerging Contributor

I do not, everything seems kosher in the expression builder window:

alex_parij_0-1726521160514.png

 

 

0 Kudos
ZachBodenner
MVP Regular Contributor

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.

0 Kudos
alex_parij
Emerging Contributor

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!

0 Kudos