Select to view content in your preferred language

Update parent table from child table in case of Delete trigger

1212
11
08-29-2023 06:24 AM
CarlosK
Emerging Contributor

 

Hi,

I have a use case where I have created a constraint in Delete trigger on ChildTable whether to allow that delete. I also have to update one column of the ParentTable from that same Delete trigger. But thats not happening.

I have multiple conditions for that calculation rule but to avoid confusion I wrote it in a simple way where I am updating the ParentTable's column "Field" on deleting ChildTable row.

return {
"edit": [{
"className": "ParentTable",
"updates": [{
"GlobalID": $feature.ParentTableId,
"Field": 1
}]
}]
}

On delete no error is coming but value of Field in ParentTable is also not updating to 1 when deleting ChildTable's row. Also ChildTable's constraint to delete row is working fine but the above attribute rule is not working

@HusseinNasser2 

Tags (1)
0 Kudos
11 Replies
BrettLessner
Frequent Contributor

Mike,

I did see that here, but I'm struggling to figure out how/where to implement it...I'm pushing the limits of my knowledge.

0 Kudos
BrettLessner
Frequent Contributor

I was able to figure this out with the $originalFeature. Again, I'm at my knowledge limits - please share any improvements that come to mind. 

I modified the Update Related template and inserted the following into the 
get_feature_set() function 

function get_feature_set(key) {
  var structures = FeatureSetByName($datastore, "Structure", ['OBJECTID', 'GlobalID', 'BM60'], false)
  var structuresSubset = Filter(structures, "ID = $feature.ID Or ID = $originalFeature.ID")
  return Decode(
    key,
    'Structure_ConduitTest', structuresSubset,
    null
  );
}

 

0 Kudos