Select to view content in your preferred language

Copy values automatically between two feature classes

1362
4
Jump to solution
10-12-2021 11:29 AM
Labels (1)
Raj-Chavada
New Contributor III

We have two feature classes in enterprise geodatabase (SQL Server). Let’s say - feature class (FC) X. FC Y. They are participating in a relationship class (1 – m). FC X is origin and FC Y is destination.

We are using ArcGIS Pro 2.7.

There is requirement to auto populate some common fields between FC X and FC Y one it is populated in FC X (origin). Is this possible to set it up using out of box solution (e.g. attribute rule – custom arcade expression calculating/copying values from FC X to FC Y based on the relationship class)

Any feedback related to developing a technical solution closely relating to this requirement will be appreciated.

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Seems like you don't find any matches in line 8. When you call First() on an empty featureset, the result will be null (line9).

if(matchfeature != null) {
  return matchfeature.TECH_REV
}
return null

Have a great day!
Johannes

View solution in original post

4 Replies
Eduardo_Fernandez_EsriAu
New Contributor II

Hello Raj 

An attribute rule should do the trick (specifically, an immediate calculation) with Arcade expression

Calculation attribute rules—ArcGIS Pro | Documentation

What exactly do you want to copy across into FCY ( for example, it is just to copy text A, concatenate A and B or do a numerical calculation between A+B) and is there any spatial operations that would trigger this event? For example, I draw a new point (an asset) within a polygon ( a park), update Address of asset based on Park Address field? This influences the arcade expression and configuration of the attribute rule.

Here are some examples - Attribute rule script expression examples—ArcGIS Pro | Documentation 

Have a look at the examples "Mark another feature as requiring evaluation" and "Edit another feature class"

Hope this helps 

Cheers Ed

Raj-Chavada
New Contributor III

Thanks for your reply and sharing documentation on the same, Ed! Yes, basically, I want to copy values from X to Y based on common ID. 

FC X = Polygon (project development)

FC Y = Line (sewer upgrades)

After reading few technical blogs - (https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/attribute-rules-and-group-temp... , https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-ed...) , with my limited knowledge of Arccade expression language I build following logic but running into issue with line 12.

RajChavada_0-1634090438356.png

 

Here is the expression that I came with so far for FC Y to copy values for TECH_REV from FC X based on common ID - DBNUMBER. After user draws lines for sewer upgrades and populate the DBNUMBER, I want this rule to fire up and get the value for TECH_REV from FC X.  

 

 

 

 

//s1 - get features from projects developments feature class
var origin = FeatureSetByName($datastore, "Project_Developments", ["DBNUMBER","TECH_REV"], false);

//s2 - get common ID from newly added feature
var dbnumber = $feature.DBNUMBER;

// s3 - filter feature based on common ID
var match = Filter(origin, "DBNUMBER = @dbnumber");
var matchfeature = first(match);

// s4 - update TECH_REV field in sewer upgrades
return matchfeature.TECH_REV;

 

 

 

 

 

0 Kudos
JohannesLindner
MVP Frequent Contributor

Seems like you don't find any matches in line 8. When you call First() on an empty featureset, the result will be null (line9).

if(matchfeature != null) {
  return matchfeature.TECH_REV
}
return null

Have a great day!
Johannes
Raj-Chavada
New Contributor III

Here is the complete and working script :

 

//s1 - get features from projects developments feature class
var origin = FeatureSetByName($datastore, "PROJECT_DEVELOPMENTS", ["DBNUMBER","TECH_REV", "CONS_Q", "CONS_YR", "CONS_DUR"], false);

//s2 - get common ID from newly added feature
var dbnumber = $feature.DBNUMBER;

// s3 - filter feature based on common ID
var match = Filter(origin, "DBNUMBER = @dbnumber");
var matchfeature = first(match);

// s4 - update TECH_REV, EST_OCC_QTR, EST_OCC_YR, EST_CON_DUR field in sewer upgrades
if (matchfeature != null) {
return {
    "result" : {
        "attributes" : {
              "EST_OCC_QTR" : matchfeature.CONS_Q,
              "EST_OCC_YR"  : matchfeature.CONS_YR,
              "EST_CON_DUR" : matchfeature.CONS_DUR,
              "TECH_REV"    : matchfeature.TECH_REV
       }
}
}
}