Select to view content in your preferred language

Automatically copy data from related table (when updated) to parent feature

305
3
Jump to solution
02-18-2025 10:39 AM
MelissaGearman
Occasional Contributor

General: I have a feature class with a related table. I want a field in the feature class to be updated to include data from the related table when the corresponding field in the related table is updated.

Specifics. I have a feature class of ROW acquisition parcels (ROWAcqParcels) and a related table (ROWAcqParcelsTable) that houses all of the relevant acquisition information for the parcels. The key for the relate is the Parcel ID Number (not sure that's relevant). When the ROW agent fills out the TITLE_WORK_RECEIVED field in the related table, I want that information to be copied to the TITLE_WORK_RECEIVED field in the feature class. 

What I currently have is shown below. The code verifies as valid when I build the expression but when I attempt to save the rule, I get an error that says there's an unexpected null, Script line:7

I've looked at a number of different posts and forums related to this and I've tried a number of the solutions but I'm not having any luck. 

 

var sourceTable = FeatureSetByName($datastore, "ROWAcqParcelsTable", ["*"], false)

var key = $feature.PIN

var selectFeature = First(Filter(sourceTable, "PIN = "))

var titleFeature = selectFeature.TITLE_WORK_RECEIVED

if (!IsEmpty(titleFeature)){
    return "Yes"
}

 

 

Thanks!!

0 Kudos
1 Solution

Accepted Solutions
MelissaGearman
Occasional Contributor

Thank you for the help! I was actually able to find something that worked at the end of the day yesterday. I followed what was done in this post: 

https://community.esri.com/t5/arcgis-pro-questions/related-table-changing-attributes-of-a-layer/m-p/... 

View solution in original post

0 Kudos
3 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @MelissaGearman,

A couple of things.

  1.  Your code isn't set to update a record from another feature class/table rather it is set to pull and update the record from the related table. Meaning that the record itself would have to be edited in order for it to populate.
  2. If you are looking to simply pull and update a record from a related table, here is the modified code below.
var sourceTable = FeatureSetByName($datastore, "ROWAcqParcelsTable", ["*"], false)
var key = $feature.PIN
var selectFeature = First( Filter( sourceTable , "PIN = @key") )
iif( !IsEmpty( selectFeature ) && selectFeature.PIN == key , "YES" , "NO" )
0 Kudos
MikeMillerGIS
Esri Frequent Contributor

You could try the Update Related AR template found in here - https://github.com/Esri/arcade-expressions/tree/master/attribute-rules/attribute_assistant

https://esri.github.io/arcade-expressions/docs/3.3/UpdateRelated.html

This will be a core Templated Attribute Rule in 3.5

0 Kudos
MelissaGearman
Occasional Contributor

Thank you for the help! I was actually able to find something that worked at the end of the day yesterday. I followed what was done in this post: 

https://community.esri.com/t5/arcgis-pro-questions/related-table-changing-attributes-of-a-layer/m-p/... 

0 Kudos