Tutorial | 01/06/20 | #WeTalkTech
How to Harness the Power of Validation Attribute Rules
As more and more businesses embark on the transition from ArcGIS Desktop to ArcGIS Pro a wider array of data management tools become available to help build robust and accurate databases.
If you are just starting out with ArcGIS Pro, a well-established user of Pro or contemplating the switch from Desktop, then this post will show you how to harness the power of validation attribute rules to enforce strict data management measures on your datasets.
We will also briefly look at what calculation and constraint rules are and the functionality they provide.
What are Attribute Rules and What Does a Validation Rule do?
Attribute rules are a set of, well, rules that you can apply to a database. These rules can perform different actions and have different triggers. The 3 types of rules are Calculation, Constraint and Validation.
These allow you to automatically populate other fields within a feature class or other feature classes within a database based on a value that the user enters. For example; a user is populating a feature class containing pole locations. If the pole is larger than 15 metres high, it must be steel. If it’s less than 15 metres high, it must be wood.
In the example in Figure 1, the material “Steel” is automatically calculated by the calculation rule as it evaluates what height the user has entered.
A Constraint rule will check what value the user has passed into a field and if it doesn’t meet the rules requirements, it will block the feature from entering the database and produce a custom error message indicating to the user why the value they have entered isn’t suitable. For example; a pole length must be between 5 and 25 metres.
In the example in Figure 2, the user enters a value of 28. The rule states that the pole must be between 5 and 25 metres. The rule was broken so false was returned, showing an error message to the user.
Now we understand what calculation and constraint rules do, we can start to look at how validation rules work… but wait! We need to first take a quick look at evaluation types!
Types of Evaluations
- Immediate calculation rules
- Constraint rules
- Batch calculation rules
- Validation rules
Immediate evaluation will run on individual rows as the edits are performed.
Deferred evaluation will run on bulk rows at a user specified time (manually triggered or scheduled).
If there are a lot of users making edits concurrently on a database, immediate calculations and constraints may become too intensive and hamper performance, to counteract this, deferred evaluation can be used to run the rules out of business hours to reduce the potential impact on performance.
Okay! Back to Validation Rules
Validation rules behave like constraint rules however validation rules will only run at a user specified time whereas constraint rules will run immediately as the data is being entered.
The Key Differences Are…
A Constraint rule WILL NOT let an incorrect value into the database.
A Validation rule WILL let an incorrect value into the database but will be flagged during evaluation.
A Simple Analogy
Tom owns a car park. The current process for receiving payment is to stop each car at the gate and request payment before entering. As Toms business grows larger, more and more vehicles arrive causing large queues which impacts how many vehicles can enter his car park each hour.
Tom decides to change his process to retroactively receive payment once the vehicles have parked by installing a payment machine. The vehicles can enter prior to paying meaning the entry queues are reduced. If the vehicle owner doesn’t have the required money to pay the parking fees at the machine, they must leave the car park.
Toms first process worked as a constraint, vehicles (features) couldn’t enter the car park (database) unless they paid the fee. This caused big queues and poor waiting times (performance).
Toms second process worked as validation, vehicles (features) could enter the car park (database) without paying however if they didn’t have the money to pay the machine, they would have to leave. This improved the waiting times (performance).
How to Setup and Use Validation Rules
Now we understand what the difference between the types of rules, let’s create a simple validation rule!
This can be achieved in 7 steps as outlined in the ArcGIS Pro Help Documentation:
- Add the attribute rule to the dataset.
- Share the dataset as a web feature layer with the Validation capability enabled.
- Make edits to the web feature layer.
- Evaluate the rules and check features using the Error Inspector.
- Review the error features and make edits to correct the errors.
- Re-evaluate the rules.
Step 1: Add the Attribute Rule to the Dataset
For this you will need a point, line, polygon or table feature inside an enterprise geodatabase with Branch versioning enabled. The feature must also have global ID’s and editor tracking enabled.
I’m going to use a simple point feature class which will show pole locations.
Right click on the layer in the contents table, navigate to Design > Attribute Rules. The Attribute Rules window will open and on the top ribbon toolbar, select the Validation Rule button.
On the right-hand side of the screen a new window will appear where you can enter details for the rule. In this example I am adding a rule that states height must be between 5 and 25 Metres.
The expression is the logic that will process when the rule is triggered, if a True value is returned, no action is taken. If a False value is returned, then the row of data the logic has processed will be flagged during evaluation.
The expressions are written in Arcade… More information can be found here!
The error information is what will be presented afterwards in the error report. This will help identify what rule has been violated if you have multiple rules.
Step 2: Share the Dataset with Validation Enabled
Share the feature class to your portal, ensure that Reference Registered Data and Validation are both selected.
Step 3: Make Edits to the Web Feature Layer
This can be completed within ArcGIS Pro or an ArcGIS Enterprise Web Application.
Step 4: Evaluate the rules and check features using the Error Inspector
Evaluating the rules and inspecting the errors is simple and can be achieved in 4 easy steps:
- In ArcGIS Pro – Open the catalog pane and add the portal item for the feature layer.
- In the table of contents, right click on the layer and select Add Error Layers.
- In the edit menu, select Error Inspector.
- In the Error Inspector window, select Evaluate Rules.
You can change filters and the types of rules to evaluate by selecting the dropdown menu next to Evaluate Rules in the Error Inspector.
Now the rules have been evaluated, you can see one feature has been highlighted. In the error inspector it states which rule has been broken and provides a description along with other useful insights.
By clicking the Features button, you can select the row in the feature layer to review the erroneous value. In this example, a height of 2 has been entered but the value must be between 5 and 25.
In the Validation Status field within the feature layer, you can see the highlighted point has a value of “No calculation required, validation required, has error(s)”. This provides quick useful information for the status of each feature.
Step 5 & 6: Review the error features, make edits to correct the errors and re-evaluate
At this point we have a few options on how to handle the errors…
- Edit the value in the feature layer to the correct height.
- Mark as exception if the height is correct.
We can manually correct values by changing the height and then selecting re-evaluate. This will remove all errors and the layers overall status will be “no validation required, no errors”.
Sometimes rules aren’t perfect and there may be instances where the rule is broken but the feature is correct.
If a point is correct, you can mark this as an exception by right clicking the space to the left of the row in the Error Inspector and selecting Mark as Exception. Now if you re-evaluate, all errors have been removed.
More information on the error inspector and the evaluation of rules can be found here!
There are many ways to fix errors. It could be an individual’s responsibility to check each error and fix them or you can use the “created_user” field from the editor tracking to send a report to the users on their errors and ask them to review and correct.
If you wish to run the evaluation out of hours, use the Evaluate Rules geoprocessing tool combined with the scheduling function in ArcGIS Pro.
Attribute rules are extremely powerful and can be utilised in many ways. They can be used to automatically calculate fields or features based on a user’s input, constrain a feature from entering the database or validate that existing features in a dataset are correct.
Validation and constraint rules are similar in how they behave however validation rules can be run in bulk out of hours at a user specified time whereas constraint rules will only be run during the edit operation.
The key benefits of using validation rules over constraints are:
- Evaluation can be run in bulk highlighting all errors in the dataset.
- They can be run outside of business hours to reduce potential performance impacts.
- Exceptions can be made if a feature doesn’t meet the rules requirements.
Ross is a GIS consultant at Esri Ireland and has over 9 years of experience in the GIS field, with most of his time spent working with the ArcGIS Desktop & Pro suites and utilising them to streamline custom processes. In his spare time, he enjoys keeping fit, walking the dog and listening to podcasts.