I have a problem when closing out an opportunity (OpportunityMaint) graph.
It is giving the dreaded “Another process has added/updated/deleted the ‘{0}’ record. Your changes will be lost.”
In the past I have handled this by simply using:
PXTimeStampScope.SetRecordComesFirst(typeof(OpportunityMaint), true);
But I can’t figure out how to override the Closed as Won method. In source code, it seems Acumatica is now adding a “workflow” class but extending the OpportunityMaint class:
class OpportunityWorkflow : PX.Data.PXGraphExtension<OpportunityMaint>
And within that, it defines the options for closing an opportunity:
var formOpen = CreateForm("FormOpen", OpenReasons, OpportunityReason.Qualified);
var formWon = CreateForm("FormWon", WonReasons);
var formLost = CreateForm("FormLost", LostReasons);
But I can’t override it.
I tried creating this:
[PXOverride]
public void CloseAsWon(PXAdapter adapter, Action<PXAdapter> baseMethod)
{
using (PXTimeStampScope ts = new PXTimeStampScope(null))
{
PXTimeStampScope.SetRecordComesFirst(typeof(OpportunityMaint), true);
// Call the base CloseAsWon action logic.
baseMethod?.Invoke(adapter);
}
}
Which compiles but errors out at runtime with an error:
Method Void CloseAsWon(PX.Data.PXAdapter, System.Action`1[PX.Data.PXAdapter]) in graph extension is marked as [PXOverride], but the original method with such name has not been found in PXGraph
What is the secret for overriding this? Anyone know?