Write Attribute from Related Table into Parent Feature - Attribute Rules

290
1
Jump to solution
09-15-2021 05:05 PM
Labels (2)
OliverSandoval_p
New Contributor II

Hello, im trying to create an immediate calculation(triggered on insert) that will take the date field of an inspection from the related table of the parent point hydrant feature into the hydrant's most recent inspection date field.  Its an SQL database and im using pro 2.8.2. I havent had a chance to set up environment to test but I just wanted to ask if im going in the right direction. Thank you!

Var inspection_date = $feature.workdate
Var related_Hydrants = FeatureSetByRelationshipName($feature, "Hydrant_Maintenance")
Var inspected_Hydrant = First(related_Hydrants)
return {
     
      "result": inspection_date,
             "edit": [
           { 
                 "className" : "related_Hydrants",
                   "updates" : [{
                     "globalID" : inspected_Hydrant.GlobalID,
                     "attributes": {
                      'Flush_Date': inspection_date
}
 
             }]
         }]
 
}

0 Kudos
1 Solution

Accepted Solutions
OliverSandoval_p
New Contributor II

Figured it out! With the help of Advanced Attribute Rules – Editing features on another class with attribute rules (esri.com)

Thanks Hussein!

Could not get it to work with FeatureSetByRelationshipName but heres what i came out with

 

var parent_id = $feature.GUID_H
Var inspection_date = $feature.Work_Date
var hydrant_class_name = "//featureclassname//"
Var related_Hydrants = FeatureSetByName($datastore, "//featureclassname_not_the_variable//",['GlobalID'], false//for return geometry, I just need attribute//)
Var parent_Hydrant = First(Filter(related_Hydrants, 'GlobalID = @parent_id'))
if (IsEmpty(parent_Hydrant)) {
return parent_id;
}
return {
"result": parent_id,
             "edit": [{ 
                 "className" : "//featureclassname_notavariable//",
                   "updates" : [{
                     "globalID" : parent_Hydrant.GlobalID,
                     "attributes": {
'Most_Recent_Inspection_Date': inspection_date
}
             }]
         }]
 
};

View solution in original post

0 Kudos
1 Reply
OliverSandoval_p
New Contributor II

Figured it out! With the help of Advanced Attribute Rules – Editing features on another class with attribute rules (esri.com)

Thanks Hussein!

Could not get it to work with FeatureSetByRelationshipName but heres what i came out with

 

var parent_id = $feature.GUID_H
Var inspection_date = $feature.Work_Date
var hydrant_class_name = "//featureclassname//"
Var related_Hydrants = FeatureSetByName($datastore, "//featureclassname_not_the_variable//",['GlobalID'], false//for return geometry, I just need attribute//)
Var parent_Hydrant = First(Filter(related_Hydrants, 'GlobalID = @parent_id'))
if (IsEmpty(parent_Hydrant)) {
return parent_id;
}
return {
"result": parent_id,
             "edit": [{ 
                 "className" : "//featureclassname_notavariable//",
                   "updates" : [{
                     "globalID" : parent_Hydrant.GlobalID,
                     "attributes": {
'Most_Recent_Inspection_Date': inspection_date
}
             }]
         }]
 
};

View solution in original post

0 Kudos