Automatically save the file generated by an XMLPort

Hi everyone,

I want to be able to save the file generated by an XMLPort into a specific location after exporting data(without the dialog box where we choose to open, save or cancel)

Is that possible? and how can i do it?

There are different solutions depending on the version of NAV you’re using. So which version of NAV is this about?

Hi

Below sample code will export records from using outstream and save in a specified location,as like below you can save file in specified location

Name DataType Subtype
TestFile File
SalesHeader Record Sales Header
TestStream OutStream

IF RecSalesHeader.FINDSET THEN
BEGIN
TestFile.CREATE(‘C:\Export.xml’);
TestFile.CLOSE;
TestFile.WRITEMODE(TRUE);
TestFile.OPEN(‘C:\Export.xml’);
TestFile.CREATEOUTSTREAM(TestStream);
XMLPORT.EXPORT(50001,TestStream,RecSalesHeader);
TestFile.CLOSE;
END;

I am using the 2013 version.

Thanks for your effort…

I am exporting to a text file…would this code work for me?

Hi Poppins,

Just change xml to txt and run your code thats all