Search code examples
acumatica

Execute PXAction after another action


I add the autorun action "Maj BFT", but I Would like execute this action after the create IN document.

WHEN I use this code, the 2 actions are impacted. I would like Wait 1000 only for genbft

public PXAction<POReceipt> Genbft;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Maj BFT",Enabled = true)] 

protected virtual void genbft()
{
  Task.Delay(1000).Wait();
}

enter image description here

enter image description here


Solution

  • Override the CreateIN document and wait for the operation to complete. Upon completion, run the code which executes your second action. Below is an example of waiting for a process to complete in a different screen...then it runs a second batch of operations/

     public delegate IEnumerable ExportDelegate(PXAdapter adapter);
        [PXOverride]
        public IEnumerable Export(PXAdapter adapter, ExportDelegate baseMethod)
        {
            baseMethod(adapter);
            TimeSpan timespan;
            Exception ex;
            while (PXLongOperation.GetStatus(Base.UID, out timespan, out ex) == PXLongRunStatus.InProcess)
            { }
            //do some more stuff after the Export action finishes