Select to view content in your preferred language

How to Toggle Constraint and Calculation Attribute Rules on and off

1485
4
02-27-2024 07:34 AM
HusseinNasser2
Esri Contributor
2 4 1,485

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

 

 

4 Comments
Bud
by
Esteemed Contributor

@HusseinNasser2 

FYI

If, for some reason (in the future), you don't want to attach FGDBs as .zips (people might have security concerns or restrictions), then you might be interested to know that mobile geodatabases are now allowed as attachments in Esri Community posts. 

Allow attaching a mobile geodatabase as a file in Esri Community posts and messages

Mobile geodatabases are convenient as attachments since they're only a single file, so they don't need to be zipped. Although, I suppose mobile geodatabases aren't supported by older versions of Pro, which might be a problem for some users.

HusseinNasser2
Esri Contributor

Thanks @Bud I used file just to support older Pro releases, 

That being said, I just tried to upload a row mobilegdb but got an error (content type octet stream doesn't match file extension .geodatabase),   the change might take time to fully propagate

 

Jake_S
by Esri Contributor
Esri Contributor

@HusseinNasser2 This is great! Also provides inspiration for other use cases 

LeviCecil
Frequent Contributor

Hello,

I'm having trouble making this work on a constraint rule. I've tested your sample in my workspace so I know it does work. Here's the arcade I'm working with 

//Start AR Check
//add a row in the aroptions table and set 1 or 0 to  enable or disable the rules
var option = first(featuresetbyname($datastore, "Attribute_Rule_Options"))
if (option != null) if (option.EnableConstraintRules == 0) return true;
//End AR Check

if (!IsEmpty($feature.assetid) && !Equals($feature.assetid, $originalFeature.assetid)) {
    return false; // Prevent the update
} else if (IsEmpty($feature.assetid)){
    return false;
}
else {
    return true; // Allow the update
}
Contributors
About the Author
Software Engineer, Author of several GIS books and Software Engineering Content Creator on YouTube and Anchor.fm podcast