Skip to main content
Question

How can I wait for a file to be created?

  • August 3, 2021
  • 1 reply
  • 205 views

Forum|alt.badge.img+6

My code is taking the file that the Batch Payments.Export action has created and set it up for file synchronization.

The challenge is that my code isn’t waiting for the file to be generated.  If I click the button again I am able to find the file and update it.

Is there a different way that I should wait for the Base.export.Press(adapter) process to finish before continuing on with the rest of the code?

 

    [PXOverride]
    public virtual IEnumerable Export(PXAdapter adapter)
    {

        Base.export.Press(adapter);
        PXLongOperation.WaitCompletion(Base.UID);

        UploadFileMaintenance fm = PXGraph.CreateInstance<UploadFileMaintenance>();

        var batchCache = Base.Caches[typeof(CABatch)];

        var fileNotes = PXNoteAttribute.GetFileNotes(batchCache, batchCache.Current);

        UploadFile theFile = (UploadFile)PXSelect<UploadFile, Where<UploadFile.fileID, Equal<Required<UploadFile.fileID>>>>.Select(new PXGraph(), fileNote);

       if (theFile == null)
       {
         return adapter.Get();
       }

        //Update the file record's fields
        theFile.Synchronizable = true;
        theFile.SourceType = "C";
        theFile.SourceUri = "the url";

        theFile = fm.Files.Update(theFile);
        fm.Actions.PressSave();        

        return adapter.Get();

    }

 

1 reply

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • October 24, 2021

Hi @ddunn  If this issue is NOT resolved, below code might help you to address this issue.

After  Base.export.Press(adapter); add below lines and verify.

PXAutomation.CompleteAction(Base);
    PXLongOperation.WaitCompletion(Base.UID);
    PXLongOperation.ClearStatus(Base.UID);

If this is already resolved, please share the solution here, so that it will helpful for others.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings