Skip to main content

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?

Hi @Leif  As you are invoking the Base.Release(adapter) action beginning of the code, and once the document is released, then the document is moved to read-only mode, and the system will not allow any changes to this document.

 


Thanks @Naveen Boga  for the reply.

I am not trying to update the ChangeOrder document after Base.Release. I am trying to update the parent project, but to do so I need to query the list of change orders. However, when I make the query, I show the newly released CO not to actually be released. However, once the action completes the database is updated.


Seems the cache was dirty, and adding ReadOnly to SelectFrom<> solved my issues.

Thanks 


Hi @Leif - thank you for sharing your solution with the community!


Reply