HOW TO

Auto-populate values based on common fields using Attribute Rules in ArcGIS Pro

Last Published: October 13, 2024

Summary

When creating features for a new feature layer, it is uncommon to refer to an existing table or an attribute table of a feature layer to populate the value of the matching field of both the table and the feature layer. When creating a large number of features, repopulating the field with the existing table may be time-consuming, or require an additional step to run the calculation. It is possible to automatically populate the data as the feature is created using Attribute Rules. 

Procedure

  1. Open a new project and add both the table and the new feature layer.
  2. Add GlobalID to the new feature layer using the Add Global IDs tool.
  3. In the Contents pane, right-click the feature layer to be drawn > Data Design > Attribute Rules.
  4. Click Add Rule. Select New Rule and enter the Rule Name. In this example, the rule name is New Rule.
  5. In the Expression text box, insert the following script. Modify the parameters below.
    • Feature_Name with the source feature layer name to be compared to. It can also be the name of the stand-alone table.
    • Matching_Field with the matching field to be compared to. In this example, the SHAPE field is used.
    • Output_Field with the name of the field in which values must be copied into the new feature. In this example, the Direction field is used.
var sourceTable = FeatureSetByName($datastore,"<Feature_Name>", ["<Matching_Field>", "<Output_Field>"], false)
var matchingAttr = $feature.<Matching_Field>
var matchedFeature = First(Filter(sourceTable, "<Matching_Field> = @matchingAttr"))
If (matchedFeature == null){
    return "not found"}
else{
    return matchedFeature.<Output_Field>}
The following is the full working script:
var sourceTable = FeatureSetByName($datastore,"House", ["OBJECTID", "Direction"], false)
var matchingOID = $feature.OBJECTID 
var matchedFeature = First(Filter(sourceTable, "OBJECTID = @matchingOID"))
If (matchedFeature == null){
    return "not found"}
else{
    return matchedFeature.matchedFeature.Direction}
  1. Check the Insert and Update check boxes under the Triggers section.
Attribute rule window for the new rule
  1. On the Attribute Rules ribbon, click Save.
  2. Draw the feature. The map below demonstrates the Direction field populated.
The desired field is auto-populated when drawing a new feature

Article ID: 000030999

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 8 x
  • ArcGIS Pro 2 9x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options