Select to view content in your preferred language

Pro arcade expression attribute rule

189
4
02-24-2025 03:52 PM
2Quiker
Frequent Contributor

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;
}

 

 

0 Kudos
4 Replies
AlfredBaldenweck
MVP Regular Contributor

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.

0 Kudos
2Quiker
Frequent Contributor

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.

0 Kudos
KenBuja
MVP Esteemed Contributor

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?

0 Kudos
2Quiker
Frequent Contributor

account was a typeo, it's should be ParcelID.

0 Kudos