Dictionary keywords expose advanced behavior of attribute rule functionality, such as returning custom error messages in conditional statements or performing edits to features in another feature class. When authoring ArcGIS Arcade expressions for attribute rules, the return dictionary type must use one of the reserved keywords listed below. To perform multiple operations, extend the dictionary with different keywords. To learn more about how to use these dictionary keywords, see Attribute rule script expression examples.
Note:
When defining global lD or global IDs keyword parameters, ensure that the value is enclosed in single quotation marks.
result
A single value or a dictionary is returned for the feature. You can only use this keyword with calculation rules.
- When using the result keyword to return a single value, you must define a target field in the attribute rule to update the correct field.
- You can return result as a dictionary to update multiple fields of the feature. When returning result as a dictionary, the target field in the attribute rule is optional. You can specify any field to update in the dictionary using the keyword parameters in the table below.
When the target field is defined in the attribute rule and you are returning result as a dictionary, keep the following in mind:
- If the target field is in the dictionary, the target field is updated with the value defined in the dictionary.
- If the target field is omitted from the dictionary, no change is made to the target field.
Note:
Using a dictionary in the result keyword is only supported with ArcGIS Pro 2.7 or ArcGIS Enterprise 10.9 and later.
Keyword parameter | Description |
---|---|
attributes | Edits specified fields. The value is a dictionary of field name and attribute pairs. |
geometry | Edits the geometry. The value is a Geometry object. |
return {
//result is a single value
//set the attribute rule target field to 200 for $feature
'result': 200
}
return {
//result is a dictionary
//set 'field1', 'field2', and the geometry for $feature
//ArcGIS Pro 2.7 or ArcGIS Enterprise 10.9 and later
"result": {
"attributes": {
"field1": 'field1', //updates field1 in the $feature
"field2": 11 //updates field2 in the $feature
},
"geometry": Rotate($feature) //updates geometry in $feature
}
}
errorMessage
A user-defined error message for a failure during evaluation is returned. Use the errorMessage keyword when creating logical statements in Arcade expressions to return custom error messages. When returning errorMessage, no other dictionary keyword can be used. See an example of how to return a custom error message.
return {
"errorMessage": "Error message text"
}
calculationRequired
Features are marked as requiring evaluation of batch calculation rules. When this keyword is used, the corresponding feature or features are marked as requiring calculation by modifying the Validation Status attribute. This keyword can only be used with calculation rules, and the Exclude from application evaluation option must be set to true. See an example of how to mark other features as requiring evaluation.
Keyword parameter | Description |
---|---|
className | The name of the feature class or table that will be modified. This parameter is required. |
objectIDs | globalIDs | An array of object IDs or global IDs that will be modified. This parameter is required. |
return {
'calculationRequired': [{
'classname': 'featureclass_name',
'globalIDs': ['{8B421724-32D0-408A-A8EE-CCC2B064D52B}']
}]
}
validationRequired
Features are marked as requiring evaluation of validation rules. When this keyword is used, the corresponding features are marked as requiring validation by modifying the Validation Status attribute. This keyword can only be used with calculation rules, and the Exclude from application evaluation option must be set to true. See an example of how to mark other features as requiring evaluation.
Keyword parameter | Description |
---|---|
className | The name of the feature class or table that will be modified. This parameter is required. |
objectIDs | globalIDs | An array of object IDs or global IDs that will be modified. This parameter is required. |
return {
'validationRequired': [{
'classname': 'featureclass_name',
'globalIDs': ['{60905A3D-9783-435D-B4C9-AA4ADA59AD32}']
}]
}
edit
Insert, update, and delete features in a specified feature classes. The edit keyword can only be used with calculation rules, and the Exclude from application evaluation option must be set to true. See an example of how to edit another feature class.
For a utility network, you can use the edit keyword to edit the association of the $feature using the associationType keyword. To edit any association in the utility network, set the className value to ^UN_Association. The ^UN_Association value allows you to access the utility network associations table to edit any association between features when using the associated keyword parameters for adds and updates.
When performing association edits using the edit keyword, the utility network rules are not taken into account during the evaluation process. The network features will be validated during network topology tasks such as enable or validate network topology.
Learn more about utility network associations
Keyword parameter | Description |
---|---|
className | The name of the feature class or table that will be modified. This parameter is required. |
The type of edit that will be made. The value is an array of dictionaries detailing the edits for each edit type. |
Note:
Do not create a script that performs recursive edits. If a script is configured to perform an edit that triggers or evaluates the attribute rule, an infinite loop is created. This causes unintended results.
adds
Use this keyword in the edit dictionary to perform inserts to a specified feature class or table.
Keyword parameter | Description |
---|---|
attributes | Edits specified fields. The value is a dictionary of field name and attribute pairs. |
geometry | Edits the geometry. The value is a Geometry object. |
associationType | Edits the association of the $feature in a utility network. Possible values include the following:
The following are additional possible values for ArcGIS Utility Network version 4 and later:
|
fromTerminal | The name of the from terminal that will be edited when the associationType value is connected, junctionEdgeFrom, or junctionEdgeTo. |
toTerminal | The name of the to terminal that will be edited when the associationType value is connected, junctionEdgeFrom, or junctionEdgeTo. |
isContentVisible | Specifies whether the content is visible for a containment association. The value is true or false. |
percentAlong | The percent along a line or edge when the associationType value is midspan. The value is a percentage ranging from 0 to 1. |
tag | A tag for a feature or record that hasn't been created yet. You can reference the tag value in other parts of the edit dictionary such as the fromGlobalID or toGlobalID keywords when editing the ^UN_Association value. The value is a unique string. Note:This parameter is only supported with ArcGIS Pro 2.7 or ArcGIS Enterprise 10.9 and later. |
Use the following keyword parameters to add an association when className is set to ^UN_Association.
Keyword parameter | Description |
---|---|
fromClass | The name of the from feature or object class participating in the association. This parameter is required. |
fromGlobalID | The global ID of the from feature or object. This parameter is required. |
toClass | The name of the to feature or object class participating in the association. This parameter is required. |
toGlobalID | The global ID of the to feature or object. This parameter is required. |
associationType | The type of association between the features in a utility network. This parameter is required. Possible values include the following:
The following are additional possible values for ArcGIS Utility Network version 4 and later:
|
fromTerminal | The name of the from terminal for a connectivity association. |
toTerminal | The name of the to terminal for a connectivity association. |
isContentVisible | Specifies whether the content is visible for a containment association. The value is true or false. |
percentAlong | The percent along a line or edge when the associationType value is midspan. The value is a percentage ranging from 0 to 1. |
return {
'edit': [{
'className': 'b_edit_dict',
'adds': [{
'attributes': {
'field_name': 11
},
'geometry': Geometry({
'x': -76.8375008,
'y': 39.4949383,
'spatialReference': {
'wkid': 4326
}
})
}]
}]
}
"edit": [{
"className": "ElectricDistributionJunctionObject",
"adds": [{ //adds a new Electric Distribution Junction Object and creates a midspan association to the $feature
"percentAlong": 0.5,
"associationType": 'midspan'
}]
}]
}
//$feature is an edge object in the utility network
//Arcade will add two junction objects and associate them to the $feature
//The junction object with asset group 5 and asset type 1 has a terminal configuration of High/Low
return {
"result": $feature.assetid,
"edit": [{
"className": "ElectricDistributionJunctionObject",
"adds": [{
"attributes": { //Adds a junction object
"assetgroup": 5,
"assettype": 1
}, //create a connectivity association between the $feature and junction object
"toTerminal": "High", //to the high side terminal of the junction object
"associationType": "junctionEdgeFrom" //on the from side of the edge object
}, {
"attributes": { //Adds a junction object
"assetgroup": 5,
"assettype": 1
}, //create a connectivity association between the $feature and junction object
"toTerminal": "High", //to the high side terminal of the junction object
"associationType": "junctionEdgeTo" //on the to side of the edge object
}]
}]
}
return { //creates two new Structure Junction Objects and creates an association between them using a tag
"edit": [{
//create two junction objects and identify them uniquely with a tag
"className": "StructureJunctionObject",
"adds": [{
"tag": "jo1", //unique identifier for new feature in the Structure Junction Object class
"attributes": {
"AssetGroup": 1,
"AssetType": 2
}
}, {
"tag": "jo2", //unique identifier for new feature in the Structure Junction Object class
"attributes": {
"AssetGroup": 1,
"AssetType": 2
}
}]
}, {
"className": "^UN_Association", //edit the association table and create an attachment association between the new junction objects
"adds": [{
"fromClass": "StructureJunctionObject",
"fromGlobalId": "jo1.globalID",
"toClass": "StructureJunctionObject",
"toGlobalId": "jo2.globalID",
"associationType": "attachment"
}]
}]
}
updates
Use this keyword in the edit dictionary to perform updates to a specified feature class or table.
Keyword parameter | Description |
---|---|
objectID | globalID | The object ID or global ID value of the feature that will be edited. This parameter is required. |
attributes | Edits specified fields. The value is a dictionary of field name and attribute pairs. |
geometry | Edits the geometry. The value is a Geometry object. |
associationType | Edits the association of the feature in a utility network. Possible values include the following:
The following are additional possible values for ArcGIS Utility Network version 4 and later:
|
fromTerminal | The name of the from terminal that will be edited when the associationType value is connected, junctionEdgeFrom, or junctionEdgeTo. |
toTerminal | The name of the to terminal that will be edited when the associationType value is connected, junctionEdgeFrom, or junctionEdgeTo. |
isContentVisible | Specifies whether the content is visible for a containment association. The value is true or false. |
percentAlong | The percent along a line or edge when the associationType value is midspan. The value is a percentage ranging from 0 to 1. |
Use the following keyword parameters to update an association when className is set to ^UN_Association.
Keyword parameter | Description |
---|---|
isContentVisible | Specifies whether the content is visible for a containment association. The value is true or false. |
percentAlong | The percent along a line or edge when the associationType value is midspan. The value is a percentage ranging from 0 to 1. |
return {
'edit': [{
'className': 'b_edit_dict',
'updates': [{
'globalID': '{7EBAB596-E9DB-40D8-9756-B2EBED2500B7}',
'attributes': {
'field_name': 22
}
}]
}]
}
return {
"result": $feature.assetid,
"edit": [{
"className": "electricdistributionassembly",
"updates": [{
"objectID": feature_objectid,
"associationType": 'container'
}]
}]
}
deletes
Use this keyword in the edit dictionary to perform deletes in a feature class or table.
Keyword parameter | Description |
---|---|
objectID | globalID | The object ID or global ID value of the feature that will be deleted. This parameter is required. |
return {
'edit': [{
'className': 'b_edit_dict',
'deletes': [{
'objectID': 22
}]
}]
}