XMLPort: Export from temporary tables

08 Aug

You can export data from tables to XML by using XMLPorts. But you can also use XMLPorts to export data from temporary tables.
The principle is to set the Temporary property on the table line and then create a function in XMLPort that inserts all the data into the temporary record.

I will start with creating a XMLPort to the Item table. I have only chosen two fields, “No.” and Description.


In order for the XMLPort to be temporary we have to set the following setting

Temporary Property on XMLPort

Lets create the function that inserts the data into the temporary table. Note that the record that I inserts to is the same record name on the XMLPort line.
Function that inserts the data into the temporary record

Once this is done I’ll create a test function that builds our temporary data, sends the data to the temporary XMLPort and then the export function on it.

    PROCEDURE ExportTempRecordsToXMLFile@1000000002();
      TemporaryItemXMLPort@1000000003 : XMLport 69790;
      TempItem@1000000004 : TEMPORARY Record 27;
      TestFile@1000000002 : File;
      Outstream@1000000001 : OutStream;
      FileName@1000000000 : Text[100];
      //Builds data in temporary records and uses a XMLport with the
      //temporary property to export the temporary records as XML

      //Build the temporary records
      //TempItem is declared as temporary
      TempItem."No." := '1';
      TempItem.Description := 'Test1';

      TempItem."No." := '2';
      TempItem.Description := 'Test2';

      //Create a stream to the destination file
      FileName := 'C:\temp\TESTXML.txt';
      //XMLPort part

      HYPERLINK(FileName); //To open the file when it is done

Once done the result is this

XMLPort export esult

1 Comment

Posted by on 2015-08-08 in Okategoriserade


Tags: , ,

One response to “XMLPort: Export from temporary tables

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

The BC Docs Librarian

Tips and news for AL programmers

Stefan Maroń

Dynamics 365 Business Central

James Pearson

Thoughts about Dynamics 365 Business Central, Git, Azure DevOps, PowerShell, Automated Testing, Visual Studio Code...and maybe some other stuff

Roberto Stefanetti BLOG

MVP & MCT Microsoft Dynamics 365 Business Central, Powershell, Azure, SQL Server


DevOps starts with culture!

Comments for DevOps ABCs Blog

Reflections from the ERP field

DevOps ABCs Blog

Reflections from the ERP field

Dynamics 365 Business Central for Partners

Reflections from the ERP field

Freddys blog

Learn something new... - then Teach someone!

Stefano Demiliani Technical Blog

Reflections from the ERP field

David Worthington's NAV Performance Blog

Micosoft Dynamics NAV Performance Testing & Optimization

Freddys Blog

Reflections from the ERP field

Marije Brummel Blog | Business Central, Azure and more...

Design Patterns, Performance, Clean Code

Ideas in the cloud

Goprowe AB

Reflections from the ERP field


Reflections from the ERP field

The NAV Viking´s Blog

- Sharing my experience in the Dynamics NAV world

Comments for

Reflections from the ERP field

Nav Can Be Fun

Its Really Fun to Work with Microsoft Dynamics Nav / D365 Business Central

%d bloggers like this: