XMLPorts Runner for Business Central SaaS

XMLPorts Runner for Business Central SaaS

i found this nice question on MS Community : “XML port and file Output” in BC SaaS https://community.dynamics.com/business/f/758/t/298825

“If you are working on the Business Central SaaS you cannot specify a network folder because the cloud doesn’t know that; In the cloud, you cannot automatically save a file in a local folder. What you can do is using a Cloud Storage provider and having a “shared folder” with an URL (for example, Onedrive).”

Other Solution\Workaround

In this case is possible to recall XMLPorts (Xmlport.Import and Xmlport.Export properties) using the STREAM objects (InStream and OutStream), in this way it is possible to pass the source files (input \ output) in the STREAMS and to pass it in execution to the XMLPort in order to be processed; very useful function for Dynamics 365 Business Central SaaS.



[Ok :=] UPLOADINTOSTREAM(DialogTitle, FromFolder, FromFilter, FromFile, NVInStream)

“Sends a file from Microsoft Dynamics NAV Server computer to the client computer.” 

[Ok :=] DOWNLOADFROMSTREAM(VarInstream, DialogTitle, ToFolder, ToFilter, ToFile)

“Sends a file from the client computer to the corresponding Microsoft Dynamics NAV Server”


Procedures for STREAMS (for XMLPorts and Reports)

procedure RunXMLPortImport()


        FileInstream: InStream;

        FileName: Text;




        Message(‘Import Done successfully.’);



procedure RunXMLPortExport()


        TempBlob: Record TempBlob;

        FileName: Text;

        MyOutStream: OutStream;

        MyInStream: InStream;

        outputFileName: Text;





        outputFileName := ‘MyOutput.xml’;

DownloadFromStream(MyInStream,”,”,”,outputFileName);  //Save in Download folder

Message(‘Export Done successfully.’);




I attached a code example (and an Ready-to-use APP) to launch XMLPorts from a page in a dynamic way, useful for Dynamics 365 Business Central SaaS.

Objects in APP:

  • Page Pag50142.XMLPortsRunner (Page to launch XMLPorts with STREAMS)
  • XMLPort Xml50140.InventoryItems (XMLPort to import Inventory Adjustements)


  • Page XMLPorts – RUNNER

Source and APP in MyGitHUb page



XMLPorts Runner for Business Central SaaS

3 thoughts on “XMLPorts Runner for Business Central SaaS

  1. I am using DownloadFromStream(MyInStream,”,”,”,outputFileName);  function in AL to download file but it ask me to save the file but I want to save my file automatically in the specifically one folder.
    Please give me suggestion for that.

  2. Similar to Sandip – I have an .al extension running a DownloadFromStream command, but I cannot seem to suppress the dialog box? I have populated both the ToFolder and OutputFilename parameters, but it still wants to bring up a dialog.

    I need to run this on a schedule, so I can’t have a dialog.

  3. hello, thank you for this post. really helpful. just have one question, the tempblob will be removed in the future release. Do you have any update on your code?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top
%d bloggers like this: