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 errorMessage.

Context

The following products implement this profile:

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 NameTypeDescriptionSince version
$datastoreFeatureSetCollectionA collection of layers in the same feature service or database as the $feature executing the script.1.5
$editcontext.editTypeTextIndicates whether the edit event is INSERT, UPDATE, DELETE, or NA (not applicable).1.10
$editcontext.editTagTextA text value originating from an attribute rule's edit dictionary. An attribute rule expression author can set editTag in a return dictionary for downstream edits triggered by attribute rules. When an edit triggers another attribute rule, the value for editTag set by the rule that triggered the edit is populated here with the value. Use this with $editcontext.editType 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
$featureFeatureThe feature being evaluated for the constraint.1.5
$originalFeatureFeatureThe previous state of the feature being evaluated.1.9
$featureSetFeatureSetA collection of features in the same table as the $feature evaluating the expression.1.13

Function bundles

Core | Geometry | Data Access

Return types

Boolean | Dictionary

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.

Use dark colors for code blocksCopy
1
2
3
4
5
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.

Use dark colors for code blocksCopy
1
2
3
4
5
if ($editcontext.editTag != "attribute rule") {
  return { "errorMessage": "This feature must be deleted by an attribute rule." };
}

return true;
  1. Data source can be a file geodatabase, mobile geodatabase, or mobile service.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.