Using Attribute Rules to Insert Values from one Polygon field to another

1001
2
Jump to solution
05-02-2022 09:12 AM
Labels (3)
phess_luckstone
New Contributor III

I am playing around a trying to create an attribute rule, I have two polygon layers, a test parcel layer and a subdivision layer.  When I create a parcel I want the subdivision name to copy over.

// This rule will populate the edited features field with a value from an intersecting feature

// Value to copy from the intersected feature
var intersecting_field = "Name";

// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'Subdivisions', [intersecting_field], true);

// Intersect the edited feature with the feature set and retrieve the first feature
var intersected_feature = First(Within(intersecting_featset, $feature));

// Check to make sure there was an intersected feature, if not, return the original value
if (IsEmpty(intersected_feature) || intersected_feature == null)
{ 
    return;
}
// If the intersected feature is null, return the original value
if (IsEmpty(intersected_feature.Name))
{
    return;
}
return {
    //result is a dictionary
    "result": {
        "attributes": {
            "ValueCopied": intersected_feature[intersecting_field]
        }
    }
};

 

So this is the code I was using however whenever I placed a parcel inside of the subdivision polygons I got this error message (Attached).

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

It's telling you that it can't find "valuecopied". Change line 26 to

"Subdivision": intersected_feature[intersecting_field]

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

It's telling you that it can't find "valuecopied". Change line 26 to

"Subdivision": intersected_feature[intersecting_field]

Have a great day!
Johannes
phess_luckstone
New Contributor III

This was it, thank you so much, thats what I get copying straight from github.

0 Kudos