Since version: 1.5
With the Attribute Rule Constraint profile, expressions can be written to evaluate whether or not a feature meets the criteria defined in the expression. This profile is used for constraint attribute rules in ArcGIS Pro. The script should return a Boolean with true indicating the feature meets the constraint criteria or false indicating it does not meet the criteria. You can also return a custom error message by returning a Dictionary of error.
Context
The following products implement this profile:
- ArcGIS Pro
- ArcGIS Enterprise
- ArcGIS Maps SDKs for Native Apps
Spatial reference
The spatial reference of the expression's data source1 determines the execution context's spatial reference.
Time zone
The time zone of the expression's data source1 determines the execution context's default time zone.
Profile variables
| Variable Name | Type | Description | Since version |
|---|---|---|---|
| $datastore | FeatureSetCollection | A collection of layers in the same feature service or database as the $feature executing the script. | 1.5 |
| $editcontext.editType | Text | Indicates whether the edit event is INSERT, UPDATE, DELETE, or NA (not applicable). | 1.10 |
| $editcontext.editTag | Text | A text value originating from an attribute rule's edit dictionary. An attribute rule expression author can set edit in a return dictionary for downstream edits triggered by attribute rules. When an edit triggers another attribute rule, the value for edit set by the rule that triggered the edit is populated here with the value. Use this with $editcontext.edit to distinguish user edits from edits made by attribute rules. The default value is "" in all Attribute rules profiles which indicates a user edit. This value may be null on other profiles. | 1.38 |
| $feature | Feature | The feature being evaluated for the constraint. | 1.5 |
| $originalFeature | Feature | The previous state of the feature being evaluated. | 1.9 |
| $featureSet | FeatureSet | A collection of features in the same table as the $feature evaluating the expression. | 1.13 |
Function bundles
Core | Geometry | Data Access
Return types
For a list of valid dictionary keywords, click here.
Example
The following expression demonstrates how to prevent a feature from being deleted unless the feature is retired.
if ($feature.lifecyclestatus == 128 || $feature.lifecyclestatus == 64)
{
return true;
}
return {'errorMessage': 'You are not allowed delete a feature until it is retired'};The following expression demonstrates how to reject deletes made directly by users while allowing deletes initiated by an attribute rule edit dictionary.
if ($editcontext.editTag != "attribute rule") {
return { "errorMessage": "This feature must be deleted by an attribute rule." };
}
return true;- Data source can be a file geodatabase, mobile geodatabase, or mobile service.