I have a method which is called after Acumatica original method is invoked. I know Acumatica’s base method when invoked, updates an existing record, creates another record with ifferent status and saves the changes. What I’m doing is to run some additional validations and if validations passed then allow to Acumatica’s base method be completed. To make this happen, I have enveloped everything into a TransactionScope. At the end either the whole process will be commited or rejected. I have put partial my code below. My problem is when I run the code outside the PXTransactionScope I can access both updated and inserted record and modify but when it is run inside the TransactionScope as they are not saved to DB after Acumatica’s base nmethod is invoked i can not access them and modify. I need this to happen inside a TS. I tried to access the Cache to see if the inserted and updated records are in Cache (Base.DACView.Cache.Cached) but I do not see the modification is passed to Cach either. Can someone help me please how can I access the Cache changes in my below code within the TS?
public PXAction<APInvoice> customAction;
nPXButton(CommitChanges = true, DisplayOnMainToolbar = true, IsLockedOnToolbar = true)]
)PXUIField(DisplayName = "My Action", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update, Enabled = true, Visible = true)]
protected virtual IEnumerable CustomAction(PXAdapter adapter)
{
using (PXTransactionScope ts = new PXTransactionScope())
{
//Execute Acumatica Original Method
Base.AcumaticaAction.Press();
// Return if Cancel Button pressed.
if (DialogData.AskExt() != WebDialogResult.OK)
{
return adapter.Get();
}
// Do some valdation stuff here and modify the oiginally created data by Acumatica
if validation not passed
{
ts.Dispose();
}
Base.Save.Press();
ts.Complete();
}
return adapter.Get();
}