Attribute rules enhance the editing experience and improve data integrity for geodatabase datasets. They are user-defined rules that can be used to automatically populate attributes, restrict invalid edits during edit operations, and perform quality assurance checks on existing features.
Attribute rules are complementary to existing rules used in the geodatabase, such as domains and subtypes. For example, domains can be assigned to an attribute field to aid in the data collection process by providing a pick list of valid values for editors. Additionally, an attribute rule can be used to restrict values for an attribute field that are not part of the domain when performing a field calculation. After rules are added to a dataset, they can be evaluated as edits take place or at a later time.
The following are examples of how attribute rules can be used in a geodatabase:
- To save time during editing, specific attribute values are automatically populated for newly created features. For example, when a new pole is created, the assetID attribute is generated based on a sequence.
- To help enforce data integrity, edits can be blocked based on a user requirement. For example, when creating or updating a single phase transformer, the phasescurrent attribute must be A, B, or C.
- Populate specific attribute values for existing features at a user-specified time. For example, the fulladdress field for existing features is populated by concatenating several text fields.
- Review existing features to ensure user requirements are maintained after field edits are made. For example, existing features can be evaluated to ensure that when a pole is taller than 65 feet, the material must be steel. Features that don't pass the evaluation are flagged as error features to be reviewed.
Rule type
When you create an attribute rule, you must specify the rule type to use. The attribute rule type chosen depends on the desired task and at what point in the editing process the rule needs to be evaluated. Review the following rule type details to determine the applicable rule type for your workflow:
- Calculation—To increase efficiency in data collection and editing, immediate calculation rules automatically populate attributes based on editing patterns. This enhances the editing experience as new features are created or as changes are made to existing data. Batch calculation rules are evaluated at a user-specified time on existing data.
- Constraint—To ensure quality data is entered into the GIS, constraint rules control data entry by user-defined requirements. This prevents invalid data entry while editing to ensure data integrity. To find data inconsistencies of existing data, use validation rules.
- Validation—To review features that violate specified attribute or geometry requirements, validation rules highlight errors in existing data. This brings awareness to affected features to improve data integrity.
Note:
The input workspace for evaluating batch calculation and validation rules depends on the type of geodatabase the dataset with attribute rules is stored in:- File geodatabase—The geodatabase is the input workspace to evaluate.
- Enterprise geodatabase—You must use a feature service with the Validation capability as the input workspace to evaluate. Learn more about sharing data as a feature service with the Validation capability.
Attribute Rules view
Attribute rules are viewed, created, and managed in their own tabular-style view called the Attribute Rules view. The Attribute Rules view can be accessed using the context menu of the dataset directly from the Catalog or Contents pane. It can also be accessed by clicking the Attribute Rules button on the ribbon; this is available in the Design group on the Data tab when an active layer in the map view is selected or when using the Fields or Subtypes view.
For more details about using this view, see Create and manage attribute rules.
Create attribute rules
Attribute rules are created for an input feature class or table as the data owner. Rules can be created in the Attribute Rules view using the Add Attribute Rule tool or imported using the Import Attribute Rules tool. Rules can be targeted for specific subtypes in the rule definition. This is helpful when you want a rule to only apply to a subset of features in a dataset.
Arcade script expressions are used as part of the rule definition to define what to calculate or the valid feature configurations. Arcade is a portable expression language that can be used across the ArcGIS platform.
Reference the Arcade profile for the requirements and global variables to author attribute rule types. The Arcade Getting Started guide and Function Index are additional resources to begin constructing script expressions for attribute rules.
Learn more about authoring attribute rule script expressions
Note:
Adding attribute rules to a dataset impacts backward compatibility:- Once attribute rules are added to a dataset, it is incompatible with ArcMap or ArcGIS Pro 2.0 and earlier. See Client and geodatabase compatibility for more information on functionality available when using mixed client and geodatabase releases.
- Newer Arcade functions impact what ArcGIS client releases can access the dataset with the attribute rule. See Compatibility of Arcade in script expressions for more information.
Manage attribute rules
Once attribute rules are established on datasets in the geodatabase, there are several ways to review and manage the rules. The Attribute Rules view can be used to display properties, make changes to existing attribute rules, and create rules. Geoprocessing tools in the Attribute Rules toolset are also available to administer attribute rules for a dataset or to script certain tasks.
The arcpy.Describe function can be used on a dataset to print the attribute rule properties. You can also view attribute rule properties using the Export Attribute Rules tool and reviewing the contents of the exported CSV file.
Attribute rules can be temporarily disabled on a dataset using the Attribute Rules view or the Disable Attribute Rules and Enable Attribute Rules tools. When in a disabled state, the specific rule will not execute for triggering events. This can improve performance for bulk data loads and is useful for periods in which rule execution must be suspended.
Attribute rules are created as a property of feature classes or tables in the geodatabase. Attribute rules can be included in the data transfer process with datasets in the geodatabase using copy and paste or the Export XML Workspace Document and Import XML Workspace Document tools. To transfer attribute rules between existing datasets, use the Export Attribute Rules and Import Attribute Rules tools. The Export Attribute Rules tool uses a CSV file to store the definition of the attribute rule. Data migration methods such as Feature Class To Feature Class and Table To Table will not transfer the attribute rules with the underlying dataset.
Note:
Sequences are excluded from the Export XML Workspace Document tool and attribute rules referencing sequences are not added to the data in the target geodatabase during Import XML Workspace Document execution.
Evaluate attribute rules and manage error features
Attribute rules can be evaluated for a dataset during an edit operation or at a user-specified time on existing data. Depending on the rule type and properties, the attribute rule evaluation will occur at different times:
- Immediate evaluation
- Immediate calculation rules
- Constraint rules
- Deferred evaluation
- Batch calculation rules
- Validation rules
Learn more about the evaluation of attribute rules
Evaluation of batch calculation and validation rules creates errors to highlight data that violate attribute rules. Each error is stored as an error feature in the error layers. Error features can be reviewed through the Error Inspector during quality assurance workflows.