Solved

Cache not persisted until after action completes

  • 10 November 2022
  • 4 replies
  • 25 views

Userlevel 1
  • Jr Varsity II
  • 12 replies

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?

icon

Best answer by Leif 14 November 2022, 22:44

View original

4 replies

Userlevel 7
Badge +12

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.

 

Userlevel 1

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.

Userlevel 1

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

Thanks 

Userlevel 7
Badge

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

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2022  Acumatica, Inc. All rights reserved