A Python Tool for Managing Geodatabase Attribute Rules

580
6
02-28-2025 07:52 AM
Labels (2)
HaydenWelch
MVP Regular Contributor
1 6 580

Explanation

Was following this post yesterday by @RPGIS and it seems that I'm not alone in hating the Arcade IDEs that are shipped with ESRI products. It also seems that most people in the community use the same workaround of copying the code from the ESRI IDE, pasting into a real IDE, then pasting back into ESRI IDE.

This workflow is an absolute pain in the butt for any complex Attribute Rule configurations and a recipe for losing track of what versions of scripts live where.

So I took it upon myself to distill some of the personal practices I use into a Python package/script that automates the extraction and insertion of plaintext Arcade into file databases with arcade-manager.

 

Examples

NOTE: All examples below will be using this example project template from ESR, specifically the Automated_QC Template Package

 

Normal Editing

When editing Attribute Rules, you normally just open the Attribute Rule pane and type your script into the editor, this is not good if you want to maintain an edit history of your code:

HaydenWelch_0-1740756319266.png

If I make a change here, and someone else goes to use this project later, there's no easy way for them to see what I've changed or even that I changed anything.

 

Extraction

Using the arcade-manager Tools, we can extract the current state of the Attribute Rules in this database to plaintext:

HaydenWelch_1-1740756616624.png

I can now open that repository in my code editor of choice and initialize a git repository:

HaydenWelch_2-1740756833582.png

 

Tracking

After making the initial commit, let's go back to that Site Address ID rule from the first screenshot and make a change:

HaydenWelch_3-1740756971788.png

Now we can re-run the Extractor tool, and open our IDE again:

HaydenWelch_4-1740757054910.png

As you can see, the changes are now detected by git! We can now add a commit message and keep track of the changes we've made.

 

Bi-Directional

It's pretty nice to be able to track Attribute Rule changes that are made in ArcPro, but what about applying changes made in your IDE?

 

Let's change how Full Address is concatenated:

HaydenWelch_5-1740757259940.png

Commit these changes to your repo, then open your ArcPro project again and go to the `Commit Rules` Tool:

HaydenWelch_6-1740757388804.png

As you can see, the changes were applied!

Understanding Messages

ArcPro allows you to have invalid rules sometimes. This can happen if a table is moved and a $datastore is lost, or if a flag got accidentally set, etc. The arcade-manager tools will report any and all errors with your rule scripts:

HaydenWelch_7-1740757552475.png

As you can see, this example database has the application evaluation flag set incorrectly for several rules, let's got fix that:

HaydenWelch_8-1740757705193.png

Now we can re-commit our repo to the database and there are no errors:

HaydenWelch_9-1740757773960.png

 

Closing Remarks

This is just a very small side project that I threw together in about 8 hours, so there are bound to be some bugs here and there. If you notice anything, please feel free to open an issue on the linked repository or share your thoughts here.

 

 

 

 

6 Comments
Contributors
About the Author
Hello! My name is Hayden Welch. I work in the OSP fiber optic design industry and focus heavily on building tools and automations for designing large scale networks using arcpy and ArcGIS Pro