cloudThing logo in white
Menu open icon
email: info@cloudthing.com
tel: +44 (0) 121 393 4700
Menu closed icon

General

Generally useful pages

Sectors

We know loads about this stuff

What we do

The Building Blocks for cloudThing Magic

How To Export to Text Files from Microsoft’s Business Central SaaS

Darren Austin – cloudThing, Lead Dynamics Business Central Developer

Before going down the development route, it’s always good to see what standard has to offer

Often during the lifecycle of a project there comes a time where you’ll need to export data from Microsoft Dynamics 365 Business Central in a particular format. Before going down the longer route of development though, it’s always a good idea to see what standard has to offer…

 

In the below example, there are “Open” and “Edit” in excel options on most pages which may offer the solution for you.

The reason I’ve chosen to share this is because I come across often the need to export payment journal lines. This will allow the customer to upload payment lines into their bank account to pay their vendors.

The below solution will cut out the process of them having to enter everything line by line into their banking software.

 

As you’d expect, the file the bank is expecting is quite strict in format.

Please note, with the introduction of data definitions this could also eliminate the need of any development, but I’ve seen many which are not possible using this method and the only option we have is to develop the solution.

 

Life has changed between NAV >  BC and CAL code to AL code. The methods / code we used in the past may not work going forward for D365 Business Central SaaS.

Below is a method we can use to extract data from NAV to a text file, this method isn’t limited to just using text files.

Development:

Firstly, lets create a codeunit and within a function to handle our code.

To begin this process we need to add some variables to support our export

  1. One InStream
  2. One OutStream
  3. One as a reference to the standard “Temp Blob” codeunit.
  4. One to handle the file name but is not 100%, you can do this is many ways.

To enable us to write text to this we will need to create an OutStream using the Temp Blog variable.

Once created use the WriteText function within the OutStream variable.

This is a basic function below but could easily be extended to use two char variables to enable line feed / carriage return to add more lines.

Lastly to get the file to the user we would use the temp blob codeunit to create an InStream and DownloadFromStream to retrieve the file

To test this is working, I create a simple page extension to the company information page

The file is downloaded to the user:

Not Quite Ready To Get Back To Work Just Yet?

CREATING A LOW CODE APP USING POWERAPPS & THE POWER PLATFORM

HOW TO FIX DATETIME STAMPS IN MICROSOFT DYNAMICS 365

MICROSOFT DYNAMICS 365: SETTINGS IN SOLUTIONS

Contact Us

Name

*

Company Name

*

Email address

*

Telephone Number

Is there anything else you'd like us to know?

© cloudThing 2020
email iconinfo@cloudthing.com
© 2020 Copyright cloudThing ltd. All rights reserved. Company registered in England & Wales no. 7510381, VAT no. 152340739