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).
Solved! Go to Solution.
It's telling you that it can't find "valuecopied". Change line 26 to
"Subdivision": intersected_feature[intersecting_field]
It's telling you that it can't find "valuecopied". Change line 26 to
"Subdivision": intersected_feature[intersecting_field]
This was it, thank you so much, thats what I get copying straight from github.