I am trying to create an attribute rule that will allow me to create a point and take the attributes from a polygon and transfer them to the point when the point is created, if it's possible. in the attribute rules i get, Error002717: invalid arcade expression, Arcade error: Unexpected null
My attribute rule
// Read the polygon layer
var poly = FeatureSetByName($datastore, "polygons");
// Find intersecting polygon
var int = Intersects(poly, $feature);
// Check if there is an intersection
if (Count(int) > 0) {
// Get the first intersecting polygon's ParcelID value
var firstPoly = First(int);
return firstPoly.ParcelID;
} else {
// If there's no intersection, retain the existing ParcelID value
return firstPoly.ParcelID;
}
Try something like this instead?
var poly = FeatureSetByName($datastore, "pol")
for (var py in poly){
if (Intersects(py, $feature)){
return py.GlobalID
}
}
I don't think you need to specify an Else here.
Using what you posted, I didn't get an error. I have both the polygon and point layer added to my map, when start editing and create the point, the point is created but the ParcelID field is not populated in the point layer. The attribute rule is setup with the following settings, immediate calculation, Field - ParcelID, triggers - both insert & Update.
Your else statement runs when there are no intersecting polygons, which is why getting the ParcelID from a null value throws an error. Where is the existing account value coming from?
account was a typeo, it's should be ParcelID.