Select to view content in your preferred language

Attribute Rules: Update Attributes

3582
16
09-16-2020 01:42 PM
by Anonymous User
Not applicable

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?

0 Kudos
16 Replies
XanderBakker
Esri Esteemed Contributor

Hi Brian Acheff ,

The error message is indicating that you cannot use the $map global variable in a field calculation of an attribute calculation rule. You should use the $datastore instead. See Profiles | ArcGIS for Developers for more information on what global variables and functions are available in each profile.

by Anonymous User
Not applicable

Xander Bakker

Thank you for noticing my simple mistake.

When I use $datastore the expression check out, but returns nothing.

I noticed the  $editcontext.editType global for attribute rules and the following expression:

if ($editContext.editType == "UPDATE"

would this need to be inserted into the expression or would I need to create a rules using this and then when field calculating call out the if ($editContext.editType == "UPDATE")  ?

 

 

 

0 Kudos
by Anonymous User
Not applicable

Xander Bakker

This checks out, but returns this error, would you be able to point me in the correct direction or if I am headed in the correct direction with this script?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Brian Acheff ,

In this screenshot on line 13 you are using as update the text 'MACOG_ID'. This should be updates array you created before. See algo the example expression called "Edit another feature class with a calculation rule." in this link: Attribute rule script expression examples—ArcGIS Pro | Documentation 

JoeBorgione
MVP Emeritus

Xander Bakker‌ helped me out here: https://community.esri.com/thread/259345-attribute-rule-for-intersecting-layer when I had a problem with updating points or lines with underlying feature layers.

That should just about do it....
by Anonymous User
Not applicable

Joe Borgione   & Xander Bakker,

Thank you for you help.

Joe's forward of his trouble with this showed me to Xander's remark to not use $feature."field name" and instead use $feature["field name"]. 

The expression was not done as an attribute rule, but rather as a geoprocessing field calculation, though I did disable then re-enable the attribute rule associated with Intersect, so I cannot be sure if the that helped at all. 

This is the correct expression:

 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Brian Acheff ,

Let me respond to this comment first. When you return the First record of an intersect, you are returning an entire record. Not only the MACOG_ID value even though it is the only attribute you are requesting. You would have to query the actual field to get the value (adding for instance ["MACOG_ID"] at the end of the line).

by Anonymous User
Not applicable

Xander Bakker‌,

I am confused by your reply, used the expression to field calculate the MACOG_ID field in the HandHold feature class (the $feature) that intersects the MACOG_Intersections_Poly. 

Could you elaborate on your reply?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Brian.Acheff ,

Maybe it is best to show what I mean it the expression:

if ($feature["MACOG_ID"] == null) {
    // first returns a feature
    var feat = First(Intersects(FeatureSetByName($datastore, "MACOG_Intersections_Poly", ["MACOG_ID"]), $feature));
    // access the attribute to return the actual value
    return feat["MACOG_ID"];
}