Loading ...

How To React On Clicking On Abort Button In Acumatica Processing Screen

Hello everybody,

today I want to leave a notice with proposal on how to program reaction on clicking of Abort button in processing screen.

Recently it become needed for me to program some functionality to happen after user clicks on button Abort of processing screen. 

In my case I needed somehow to program exit from some threads which were running in parallel and I needed to finish one iteration of threads and then exit from each of those threds.

One more point was that just terminating of threads was also a bad idea. After a while I have found IPXCustomInfo interface. With that interface you can gain control on what to do in case of user 

clicking on Abort button. In my case I did the following:

  1. Created my own implementation of IPXCustomInfo like this:
public class PXImportCallback : IPXCustomInfo
{
    public void Complete(PXLongRunStatus status, PXGraph graph)
    {
        switch (status)
        {
            case PXLongRunStatus.Aborted:
                PXDatabase.Update<Sync>(
                    new PXDataFieldAssign<Sync.lastModifiedDateTime>(DateTime.Now),
                    new PXDataFieldAssign<Sync.wasExecuted>(false));
                break;
 
            case PXLongRunStatus.Completed:
                break;
 
            case PXLongRunStatus.InProcess:
                break;
 
            case PXLongRunStatus.NotExists:
                break;
        }
    }
}

As you can see, very simple interface, which requires of you to implement only one method: Complete, and inside of that method program supposed reaction.

Then for each StartOperation I've added following lines:

PXLongOperation.StartOperation(thisdelegate
{
    PXLongOperation.SetCustomInfo(new PXImportCallback());
 
    var orderFromDb = PXSelectReadonly<

and that's all! Each time users clicks on Abort, my programmed reaction appears, and I can clean memory and delete no longer needed files.