Attribute Rule to update automatically on update

11-29-2021 11:50 AM
Status: Open
New Contributor II

It would be great to have an Attribute Rule which updates a feature class based on an intersect of another layer when a value of the intersecting layer is updated.  Upon creating and / or updating this can be done using Arcade, however, if an attribute is being populated based off the intersecting shape there is currently no Attribute Rule which automatically updates the intersecting layer(s) when an attribute is changed. 


For example, a zone polygon feature class contains an attribute ‘inspector name’.  There is a point feature class of poles to be inspected and within this point layer there is an attribute which populates the inspector based on the zone polygon. An attribute rule can be created for create / update so if a point is placed within that zone polygon the name of the inspector would populate the point layer. However, if the inspector of that zone is changed (aka new name), the associated points within that zone do not automatically update.

1 Comment

You have to create an attribute rule in the zone polygon fc for that:

// Attribute Rule on the polygon FC
// triggers: Update
// field: empty

// if Inspector didn't change, do nothing
if($feature.Inspector == $originalfeature.Inspector) { return }

// load the points
var poles_fs = FeatureSetByName($datastore, "Poles", ["GlobalID"], true)

// get the points inside the polygon
poles_fs = Intersects(poles_fs, $feature)

// create and fill an array with edits to the point fc
var updates = []
for(var pole in poles_fs) {
  Push(updates, {"globalID": pole.GlobalID, "attributes": {"Inspector": $feature.Inspector}})

// return
// instead of returning a value for a single field, you can return a dicitionary. for more info on that:
return {"edit": [{"className": "Poles", "updates": updates}]}