I have a pair of DACs that are in a loose header/detail relationship. It isn’t directly parent/child but the header and detail fields are joined by shared data value, like a transaction number.
The header DAC is linked to a field on SOLine using the same transaction number value.
If the user attempts to delete the SOLine record, I want to check to see if it is okay to delete the related Header DAC. The Header DAC, in turn, needs to see if the detail DAC records can be deleted.
If the Header DAC and Detail DAC records can be deleted, then I’ll let the SOLine.RecordDeleting event continue. If there is a problem, I’ll set e.Cancel = true.
My question is - in what event should I do the deletion of the related DACs? I need to instantiate a PXGraph for the Header and for each of the Detail records (each one could be a different PXGraph) because there are other tables that need to be updated.
I’m not supposed to be creating PXGraphs in event handlers (I believe).
Do I do this in SOLine.Persist when it is processing the deletion and create the HeaderGraph to invoke it’s Delete logic (which will, in turn, call the DetailDAC delete logic in the headerGraph.Persist method)? I’ll wrap these in a transaction so if there is a failure everything will roll back.
Best answer by Brian Stevens
View original