I have old features that I am adding via copy and paste to a current production feature class that has attribute rules enabled. I am having trouble figuring out a way to update "at will" specific fields that are null for the old features being brought in.
The attribute rule for the current feature populates point data fields with data from a polygon boundary vi INTERSECT, but when I perform the copy and past the fields remain null and are not updated via the attribute rule.
I know with attribute assistant you can "Run Change Rules for Selected Features" is there a simple way to do this with attribute rules or mimics the rule using ARCADE or Python in the field calculator as I attempted below?
Ahhhhh I now get why it is important to format my ARCADE syntax using VAR and not just throwing together a sandwich of functions. They are not one in the same but different
I am learning to overcome this type of bad habit in Python scripting & expressions, so thank you for your critique!
Hi Brian.Acheff ;
The error you are receiving may be caused by not having a result in the intersection. Can you try this?
// don't do any intersects if you are not going to use it
if (IsEmpty($feature.MACOD_ID)) {
// intersect the data (don't retrieve the geometry when you don't need it)
var fs = Intersects(FeatureSetByName($datastore, "MACOG_Intersections_Poly", ["MACOG_ID"], False), $feature);
// count the resulting features
var cnt = Count(fs);
// don't try and access the first feature if there are no features
if (cnt > 0) {
// get the first feature and return the MACOG_ID
var feat = First(fs);
return feat["MACOG_ID"];
}
}
For intersecting underlying features, that's what works for me.
It checks out, but returns Null
If you have applied the attribute rule to the class, and it is set for update, you can trigger an update by simply calc'ing a field to itself.
That's a cool trick. Thanks Michael Miller!