How to Toggle Constraint and Calculation Attribute Rules on and off

02-27-2024 07:34 AM
Esri Contributor
2 3 429

We hear this requirement very often from customers in geonet and the conferences; Is there a way to temporarily disable all immediate attribute rules? 

While out of the box there isn't a way to do that as it requires changing the schema (physically disabling each rule and stopping any services), I thought I'd share a workaround for users who really want to implement this in their system.

By adding an "options" table with a column EnableAR, we can have each rule before it executes checks this table and reads the value at runtime. If the value is 0 the rule immediately returns, if the value is 1 the rule logic executes as normal. 

I made an example here (attached) and a video to demonstrate 


With this approach you can quickly toggle all attribute rules execution and you can even control what type rules you want to enable and disable. The downside of this is you have to update all your rules to start using this check, but once you do you are good to go. The other thing to watch out for is in multi-user environment one user can toggle this option to disable the rule and post it to DEFAULT effectively disabling the rules for all users which is something you might not want. You can of course add additional checks to prevent this logic in DEFAULT using the gdbVersion function.


Filegdb with code attached



About the Author
Software Engineer, Author of several GIS books and Software Engineering Content Creator on YouTube and podcast