Question

How can I wait for a file to be created?

  • 3 August 2021
  • 0 replies
  • 13 views

Userlevel 2
Badge

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();

}

 


0 replies

Be the first to reply!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved