Solved

Copy Paste fails to save on third layer master-detail-detail screen

  • 6 April 2022
  • 7 replies
  • 81 views

Userlevel 7
Badge +9

I have customized Acumatica’s Cost Projection Screen (PM305000) as follow

 

It basically have added a second grid to “Revision Log” as child to “Projection Line” grid to keep the history of changes on projection lines. Also I have customized Acumatica’s standard copy paste function to copy the “Revision Log” to the new projection revisions. The method code is as follow:

 

        protected virtual void CreateNewProjectionWithLog(PMCostProjection original, PMCostProjectionCopyDialogInfo info)
{
PMCostProjection newDoc = new PMCostProjection();
newDoc.ProjectID = original.ProjectID;
newDoc.ClassID = original.ClassID;
newDoc.Description = original.Description;
newDoc.RevisionID = info.RevisionID;

CostProjectionEntry target = PXGraph.CreateInstance<CostProjectionEntry>();

target.Clear();
target.SelectTimeStamp();

newDoc = target.Document.Insert(newDoc);

foreach (PMCostProjectionLine line in Base.Details.Select())
{
PMCostProjectionLine copy = (PMCostProjectionLine)Base.Details.Cache.CreateCopy(line);
copy.RevisionID = newDoc.RevisionID;
copy.NoteID = null;
copy.Mode = ProjectionMode.Manual;

copy = target.Details.Insert(copy);
copy.Mode = line.Mode;

target.Save.Press();
foreach (UDCTPMCostProjectionRevisionLog log in RevisionLogsView.Select())
{
UDCTPMCostProjectionRevisionLog logCopy = (UDCTPMCostProjectionRevisionLog)RevisionLogsView.Cache.CreateCopy(log);
logCopy.RevisionID = copy.RevisionID;
logCopy.LineNbr = copy.LineNbr;
logCopy.NoteID = null;

logCopy = RevisionLogsView.Insert(logCopy);
target.Save.Press();
}
}

target.Save.Press();
PXRedirectHelper.TryRedirect(target, PXRedirectHelper.WindowMode.Same);
}

 

My copy operation successfully copies Projection Document (Acumatica Table) and Projection Line (Acumatica Table) but fails to “SAVE” the Revision Log (Custom Table) . Can someone shed some light what I’m doing wrong?

icon

Best answer by darylbowman 6 April 2022, 23:16

View original

7 replies

Userlevel 6
Badge +4

Change

newDoc = target.Document.Insert(newDoc);

for

target.Document,Current =  target.Document.Insert(newDoc);

Userlevel 7
Badge +9

Thank @Leonardo Justiniano 

My Document is inserted and saved as Lines do. My issue is on the third table “RevisionLogsView” which is not been saved. By the way I tested your suggestion but it didn’t work.

Badge +11

I believe this is incorrect, unless I’m misunderstanding your situation:

logCopy = RevisionLogsView.Insert(logCopy);
target.Save.Press();

 

I believe it should be:

logCopy = target.RevisionLogsView.Insert(logCopy);
target.Save.Press();

 

Userlevel 7
Badge +9

Thank you @darylbowman  

 

“target” is Acumatica’s original graph. “RevisionLogsView” doesn’t exist in that graph. It is a dataview in my graph extension.

Badge +11

My mistake. I believe you’d want:

logCopy = RevisionLogsView.Insert(logCopy);
Base.Actions.PressSave();

 

Userlevel 7
Badge +9

@darylbowman  I have tried this and I get an error “Error: Another process has updated the 'PMCostProjection' record. Your changes will be lost.”

Badge +11

Ok, yeah. You should get the graph extension from 'target' with:

var targetExt = target.GetExtension<yourGraphExtension>();

Then:

logCopy = targetExt.RevisionLogsView.Insert(logCopy);
target.Save.Press();

 

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 — 2024  Acumatica, Inc. All rights reserved