During or shortly after the Release action for a ChangeOrder I would like to perform additional updates to the related Project. However, I am not sure how to do this in a way where the Release action is full persisted before continuing.
Below I have attempted to handle the standard release action (Base.Release), and then tag on a function call (SetCurrentOrderSet) to update the project, however since the Release action has not been persisted my logic in SetCurrentOrderSet fails.
public class ChangeOrderEntry_Ext : PXGraphExtension<ChangeOrderEntry>
{
public PXAction<PMChangeOrder> release;
PXUIField(DisplayName = "Release")]
PXProcessButton]
public virtual IEnumerable Release(PXAdapter adapter)
{
var result = Base.Release(adapter);
PMProject prj = this.Base.Project.Current;
ProjectEntry prjGraph = PXGraph.CreateInstance<ProjectEntry>();
ProjectEntry_Extension prjGraph_Ext = prjGraph.GetExtension<ProjectEntry_Extension>();
prjGraph_Ext.SetCurrentOrderSet(prj);
return result;
}
}
I have tried to use the RowPersited event to call SetCurrentOrderSet but am unable to initialize a graph inside the function without error.
How could I better handle this logic?