HOW TO

Auto-populate values from another table based on a common field using attribute rule in ArcGIS Pro

Last Published: September 5, 2023

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 big number of features, repopulating the field with the existing table may take time, or an extra steps by running the calculation. It is possible to automatically populate the data as the feature is created by using attribute rule. This article describes how to do so.

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 following parameters:
    • 'Feature_Name' with the source feature layer name to be compared to. It can also be the name of the standalone 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 which values are to 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 matchedFeature = First(Filter(sourceTable, "<Matching_Field> = $feature.<Matching_Field"))
If (matchedFeature == null){
    return "not found"}
else{
    return matchedFeature.<Output_Field>}
The following is the sample of a working script:
var sourceTable = FeatureSetByName($datastore,"House", ["OBJECTID", "Direction"], false)
var matchedFeature = First(Filter(sourceTable, "OBJECTID = $feature.OBJECTID"))
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 sample below demonstrates the Direction field being 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