I use attribute rules to populate fields as features are created or updated, often based on other layers. For example, we have an operational layer that divides the city into 5 regions. Each region has a different inspector, and occasionally the boundaries change. When those boundaries change, I need to be able to update the layer(s) that depend on those boundaries.
Does anyone have a succinct way of dealing with this?
The best I've got at the moment is to delete the attribute rule, run the calculation manually with Field Calculator, and then reapply the attribute rule.
If anyone finds this and just wants my script, here you go (modified for the common use of an address layer grabbing the zip codes).
var z = FeatureSetByName($datastore, 'geo.sde.Zip_Codes', ['zip'], false);
var y = First(Intersects($feature, z));
if (y == null) return;
return y.zip;
It is possible to force attribute rules to fire on other features when a feature is modified using the calculationRequired dictionary keyword. So you could create an attribute rule that fires whenever the shape on the polygon is modified (check to see if the shape is modified or use a triggering field if using 3.4 or later) or a new polygon is created.
This will work well for reasonable amount of edits. But if you're dealing with thousands of features being modified every time this happens it will likely be better for you to do something similar to your current workflow, except instead of deleting the attribute rule just disable/enable it.
If you're dealing with A LOT of features that need to be modified it'd be even faster to do the calculation using a spatial join to calculate the new values and identify any features that need to be updated (using a search/update cursor to push the new values).