Since version: 1.5
With the Attribute Rule Calculation profile, expressions can be written to update field values based on expression logic. This profile is used for calculation attribute rules tools in ArcGIS Pro. When the attribute rule is evaluated for a dataset, the return value for the expression is cast to the field type of the output value. It is best practice to handle casting within the script for full control of casting behavior to Number, Date, or Text return types.
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 |
$feature | Feature | The feature being calculated. | 1.5 |
$originalFeature | Feature | The previous state of the feature being calculated. | 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 | Database
Return types
Number | Text | Date | DateOnly | Time | Dictionary
For a list of valid dictionary keywords, click here.
Example
The following expression demonstrates how to generate a unique id for each feature, if not already set.
//Define the leading text, the trailing text and the delimiter for the ID
prefix = "ABC"
join_char = "-"
suffix = "XYZ"
//Ensure the ID is not already set, if it is, return the original id
if (IsEmpty($feature.assetid)) {
// If you do not want to use a prefix, or suffix, remove it from the list
return Concatenate([prefix, NextSequenceValue("GDB_SEQUENCE_NAME"), suffix], join_char)
}
else {
return $feature.assetid
}
- Data source can be a file geodatabase, mobile geodatabase, or mobile service.