Skip to main content
Answer

Loading child caches

  • October 13, 2022
  • 2 replies
  • 116 views

Forum|alt.badge.img+1

Hello,

I think I’m missing something obvious but I’m struggling.

I’ve overridden the ConvertQuoteToProject method on Project Quotes (PM304500).
The baseMethod is called and this creates a project, I use SelectFrom to get the PMProject object and this contains the data I would expect.
Now I want to access the RevenueBudget data but this is returning a null value. Is there a way for me to force Acumatica to load data into this child cache?
My code is below, the final if statement always resolves to true because the Cache for RevenueBudget is null.
I found the load method which I thought might fill the cache but it didn’t seem to work-  graphProjectEntry.RevenueBudget.Cache.Load()

public delegate void ConvertQuoteToProjectDelegate(PMQuote row, ConvertToProjectFilter settings);
[PXOverride]
public void ConvertQuoteToProject(PMQuote row, ConvertToProjectFilter settings, ConvertQuoteToProjectDelegate baseMethod)
{
baseMethod(row, settings);
int? projectID = row.QuoteProjectID;
PMProject pmProject = SelectFrom<PMProject>.Where<PMProject.contractID.IsEqual<@P.AsInt>>.View.Select(Base, projectID);
if (pmProject == null) { return; }
ProjectEntry graphProjectEntry = PXGraph.CreateInstance<ProjectEntry>();
graphProjectEntry.Project.Current = pmProject;
graphProjectEntry.Project.Update(pmProject);
if (graphProjectEntry.RevenueBudget.Cache.Current != null)
{
//do some work with the RevenueBudget lines
}

}

Thanks for looking

Steve

Best answer by stephenward03

I knew I’d missed someone obvious. The child caches can be refreshed easily with

graphProjectEntry.RevenueBudget.Select();

 

Or loop through with
 

foreach (PMRevenueBudget item in graphProjectEntry.RevenueBudget.Select())
{
//do some work with the RevenueBudget lines
}

 

2 replies

Forum|alt.badge.img+1
  • Author
  • Varsity III
  • Answer
  • October 13, 2022

I knew I’d missed someone obvious. The child caches can be refreshed easily with

graphProjectEntry.RevenueBudget.Select();

 

Or loop through with
 

foreach (PMRevenueBudget item in graphProjectEntry.RevenueBudget.Select())
{
//do some work with the RevenueBudget lines
}

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • October 13, 2022

Thank you for sharing your solution with the community @stephenward03 !