Afternoon everyone. I have created an attribute rule that when i update a field in one polygon, it updates the same field in an intersecting polygon. When I check the expression to validate it, it says it is valid. When I run it, I recieve and error message stating, " The index passed was not within the valid range." Any ideas on why this may occur?
Pro validates your expression based on a subset of records, so it may not know about potential values elsewhere in your data. Or for a spatial operation, it sees that the expression is valid, but once it tries to perform the steps you wrote, it hits an error.
For intersections, that usually means you've got a feature that does not intersect with anything from your other layer. If you don't have it already, throw in a quick check to make sure that the intersection has features in it.
// your other code here
// let's call the intersection "xs"
var xs = Intersects($feature, someOtherLayer)
// add a check, if there are > 0 features, do what you need
if( Count(xs) > 0 ){
return First(someOtherLayer)['someAttribute']
} else {
return 'No Intersecting Feature Found'
}
Just a comment on Josh's code. Calling Count and then First results in an extra query. For optimal performance, just call First and check if the result is valid.
var xs = Intersects($feature, someOtherLayer)
var intersected_feature = First(someOtherLayer)
if (IsEmpty(intersected_feature)){
return 'No Intersecting Feature Found'
}
return intersected_feature['other_attribute']
Thanks!