4 Jun’19

D365 Business CentralWorkaround to XMLPort not supported in Business Central

Problem Statement:

While I was working on some custom EFT project, I thought of using XMLPort as it is the safest and easiest method to get the data successfully directly from the tables. Unfortunately, XMLPort is not supported to work on WebClient and I was stuck with writing code to do exactly what XMLPort would do.Also, another issue that Business Central d extension support is using File methods i.e Open, Write, Close, etc.










 

Introduction:
In Business Central even if you’re not given explicit rights to deal with files directly there are streams using which we can be downloaded as files. Enough of introduction, let’s start working now!

Pre-requisites:

  • VS Code
  • AL Language Extension
  • Microsoft Dynamics Business Central.

Demonstration:
1. Creation of File Contents:
In this case, I’ve simply text string ‘Hello World!’
Although it’s perfectly possible to create more complicated strings such as XML contents using a combination of loops and text manipulating functions as needed.

 

 



2. Creation of Streams:
Using  TempBlob.Blob.CREATEOUTSTREAM(Var_OutStream) initialize the OutStream.

 

 

 

Using Var_OutStream.WriteText(Var_FileContent) write the text to the BLOB

 

 

 

Using TempBlob.Blob.CREATEINSTREAM(Var_InStream) read the contents of BLOB to InStream variable.

 





3. Downloading the contents of the Streams to a file:
Using DownloadFromStream(Var_Instream,FileName.FileExtension) download the contents of the InStream to a file.

 

 



Output:

 















Conclusion:
That’s exactly how I was able to create a Custom Text File and download it in Business Central. You can even try with any type of text-based exports.

Written by

Olister Rumao

Software Engineer

Leave a Reply

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

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Expenses in PSA for Fixed Bid and T&M contracts

    23 August’ 2019

    Problem Definition: One of my clients decided to use Expense module in PSA and to his surprise he could see the amount v...

    Read more
  • Setup Dockers

    23 August’ 2019

    Docker is an independent container platform that enables organizations to seamlessly build, share and run any applicatio...

    Read more
  • Qualify Lead in D365 CE: Select which entity records should be created

    20 August’ 2019

    Wave 2019 Updates brought some really sought-after features. Another one which I would like to bring up is the Lead Qual...

    Read more
  • Early Opt-in for October 2019 Wave 2 Updates

    20 August’ 2019

    August 2, 2019 was when the Wave 2 Updates were to be out. And here we are! By now, you should have gotten the option to...

    Read more
  • Setting Unified Interface App Icons

    20 August’ 2019

    Default App Icons for typical D365 environment look like these.But here’s what you can do to change these to put...

    Read more
  • We respect your privacy.
  • This field is for validation purposes and should be left unchanged.