Skip to main content

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?

Change

newDoc = target.Document.Insert(newDoc);

for

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


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.


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();

 


Thank you @darylbowman  

 

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


My mistake. I believe you’d want:

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

 


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


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