Hello, all!
I have a task I can’t solve. I make an XMLPort which imports sales Orders from XML files. There is a directory at NAS with XML files (first dir) and a directory at NAS with archive XML files (second dir). I made a button. When user press this button, NAV finds all XML files in 1st dir, runs XMLPort for all files in series (This step creates sales Orders and lines) and move files to 2nd dir. All works correctly, but I need to NAV automatically run this XMLPort without users action. Any idea?
Code of OnAction trigger of page action:
////// Action //////
SalesSet.GET;
DirectoryInfo := DirectoryInfo.DirectoryInfo(SalesSet.“Orders from Customers”);
List := DirectoryInfo.GetFiles(’*.XML’);
enumerator := List.GetEnumerator;
WHILE enumerator.MoveNext DO
BEGIN
FileInfo := enumerator.Current;
xmlPortUploadOrder.FILENAME(SalesSet.“Orders from Customers” + FileInfo.Name);
xmlPortUploadOrder.RUN;
CLEAR(xmlPortUploadOrder);
FileInfo.CopyTo(SalesSet.“Archive Orders from Customers” + FileInfo.Name, TRUE);
FileInfo.Delete;
END;
////// Action //////
Where
Name DataType Subtype Length
DirectoryInfo DotNet System.IO.DirectoryInfo.‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
FileInfo DotNet System.IO.FileInfo.‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
List DotNet System.Collections.Generic.List`1.‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
enumerator DotNet System.Collections.IEnumerator.‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
SalesSet Record Sales & Receivables Setup
xmlPortUploadOrder XMLport Orders From Web