ArcGIS Blog

Data Management

ArcGIS Pro

Prevent Infinite loops in Attribute Rules

By Hussein Nasser

Consider this table, we have two fields: group_name and common_name. The common_name must match for all rows within the same group.

We would like to create an attribute rule that ensures if the common_name is updated for a row, all rows within the same group receive the same name. This rule is straightforward; however, due to the attribute rules’ nature, updating the common_name will trigger the rule again. This repeated triggering can lead to attempting to update the same rows repeatedly, causing a cycle and potentially exhausting the Arcade engine execution instances. Resulting in the infamous error:

“The evaluation of attribute rules is cyclic or exceeds maximum cascading level”

 

Let us author the rule anyway to prove this.

 

This rule works for groups of rows with a few rows but fails when there is a large number of rows to be updated.

attribute rules cyclic infinite loop

To work around this issue, we need to differentiate between edits made by the user and edits made by the attribute rules. To achieve this, we can either add a new field or utilize an existing field in the table to indicate that the rule performed the update. During attribute rule execution we will set a specific value in this field (e.g. 1) to indicate the edit has been triggered from an attribute rule.

Subsequently, we will incorporate logic to revert the field value back to its original state, ensuring no impact on the data or schema.

I will introduce a new field called “t” and populate it with random values. It is important to note that these values will remain unchanged; they will temporarily alter during editing and then be reset back to their original values.

And when we attempt to edit, you can see that the values update correctly without any errors, and the field we used to indicate attribute rule edits remains unchanged.

Preventing loops in attribute rules

 

Ideally, we want to incorporate core functionality to achieve this within attribute rules (potentially within $editContext). We are still in the process of considering how to implement this. We will update the blog once this functionality is implemented. In the meantime, this workaround should suffice.

You may download the sample geodatabase here.

Share this article

Subscribe
Notify of
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments