ArcGIS API for Python

A Python script to Automate Attribute Rules Deployment

Attribute rules are authored using the Arcade scripting language. They are deployed to the geodatabase, optionally published to ArcGIS Enterprise and can be consumed by various client applications. However attribute rules are not static; You might want to change them as you find issues with expressions you’ve authored, want to introduce a new feature to your script, enable new editing triggers, or simply add more verbose descriptions.

When managing large number of attribute rules across multiple classes in your geodatabase it can become challenging to deploy fixes or updates to the attribute rules.  In this short blog I describe how you can automate attribute rules deployments using Python when making changes to Arcade expressions.

Attribute rules are part of the geodatabase schema, just like fields, subtypes, domains etc. This means when attempting to update an attribute rule in a table, you will need to make sure the table is not opened by other applications or services. Stopping all services and applications using that table will release any shared lock that has been acquired and allow attribute rules to be changed (by acquiring an exclusive lock). Locks are a common practice in the geodatabase to maintain the consistency and integrity of the data definition in the geodatabase model. Attribute rules can be updated from the grid view in ArcGIS Pro, GP tools, or Python.

The attribute rules grid view
The attribute rules grid view
Attribute rules gp toolbox
Attribute rules gp toolbox

It is common practice to update attribute rules in the primary geodatabase (source of truth) and later apply the changes to downstream geodatabases that might have been shared with other parties. Making these attribute rules changes manually can be daunting especially if you have hundreds of attribute rules spread across multiple classes.

Shared below is a Python script that reads attribute rules across all classes from geodatabase A (source of truth). The script then updates the attribute rules in the corresponding target geodatabase B. This script is provided as an example. Note that this script assumes all attribute rules already exist on the target and only updates the Arcade expression of the attribute rule. You can make modifications to the script to make it update triggers, rule descriptions, or other attribute rules properties.

About the author

Product Engineer at Esri, Author of several GIS books and Software Engineering Content Creator on YouTube and a podcast host.

Notify of
Inline Feedbacks
View all comments

Next Article

ArcGIS Utility Network at the 2024 Esri User Conference

Read this article