We have been working on setting up attribute rules (constraint and calculation) in ArcPro 2.7, on a ms sql server sde geodatabase. ArcPro Editing Session options are Enable and disable editing for the Edit tab is checked and Automatically save edits is unchecked.
The constraint attribute rule provides editing permission based on the feature's geometric relationship with features in a management areas feature class. A separate table has been created listing all users, the feature class and management areas the user is allowed to edit in. For example, a typical user may only have permission to edit in one management area. So the user name, the feature class and the areas (number values) where the user is allowed to edit are a row in a table. If the user tries to insert, modify, or delete a feature in a management area where they do not have permission to edit, it will be blocked. A GIS Coordinator would typically have permission to edit their own management area and the adjacent management areas. This would allow them to edit features which have a shared edge with an adjacent district. The third permission level is statewide. This is for a program specialist who may need to edit features anywhere in the state. The final permission level is Read Only. This user can only view data and not edit it.
The constraint rule checks the permissions table to see if the user has statewide editing permissions. If they do, the edit is allowed to proceed. If not, the attribute rule looks at combinations of intersects, intersection, within, and touches geometry functions to determine if the user has permission to edit in the management area where the feature or part of it falls. If a management area is found where the user does not have permission to edit, the constraint rule returns "false" and the edit is blocked. If the edit is completely within management areas where the user has permission to edit, true is returned.
One particular feature class has more calculation attribute rules than other feature classes. The constraint rule works until the seventh calculation rule is added. Once the seventh rule is added, the constraint rule allows the geometry of a new feature to be created but then blocks the editing of it's attributes. This is kind of a trap. The user can end up creating a feature that they don't have permission to edit or delete (If they save the edits).
I tried leaving "Excluded from application evaluation" unchecked for the constraint rule and checked for the calculation rules. This should allow the constraint rule to trigger in ArcPro while the calculation rules fire when sent to the database. Using ArcGIS Diagnostic Monitor it looks like the calculation rules fires before the constraint rules regardless of the setting.
I tried changing the order of the calculation rules to see if a particular calculation rule was causing the problem. That does not seem to be the case. It's hard to tell but it appears that if there are enough calculation rules ArcPro has enough time to finish enough of the insert operation to create the geometry of a new feature before the constraint rule is able to run and block the geometry insert (creating the feature). Once the new feature is created, the constraint rule successfully blocks any attempt to edit the feature. The user can discard edits but if they don't notice what has happened and save their edits, they are inserting and saving a feature they do not have permission to edit.
Is this expected behavior for some reason? Or is there a way to ensure the constraint rule running before the new geometry is written into the feature class? I can add some code in the first calculation rule expression that checks the geometry but it seems awkward using a calculation expression as a constraint also.