How To Export To Text Files From Microsoft’s Business Central SAAS

How To Export To Text Files From Microsoft’s Business Central SAAS

Darren Austin

Lead Dynamics Business Central Developer|Kerv Digital

Published 06/07/22 under:

Have a question?

Get in touch

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:

 

 

 

 

 

Related Articles

You might also be interested in

From our world to yours

Why the SLA isn’t enough – what really matters when choosing an...

From our world to yours

Accelerate your communications compliance with MS Teams

From our world to yours

What Makes a Good Managed Service Provider

From our world to yours

A Deep Dive Into Data Science

From our world to yours

Life at Kerv as a Commercial Director

From our world to yours

The importance of sustainability and the changes we need to make

From our world to yours

Decision Making Problems & How To Navigate Them

From our world to yours

Microsoft Cloud For Nonprofit: Campaigns

From our world to yours

Email vs Messaging: The Search for a Better Customer Experience

From our world to yours

Life @ Kerv Digital As A Full Stack Developer

From our world to yours

Microsoft Cloud For Nonprofit: Volunteers

From our world to yours

A Kerv Digital & Firebrand Training Success

From our world to yours

Going Beyond The Theory: Kerv Digital & The DVSA

From our world to yours

Life @ Kerv Digital As A Performance Analyst

From our world to yours

Four ways to defend against Cyber Criminals attempt to infiltrate Contact Centres

From our world to yours

Microsoft Cloud For Nonprofit: Fundraising & Engagement

From our world to yours

Kerv Group brings rich, actionable insights to bear on improving performance management...

From our world to yours

4 ways to integrate your Contact Centre and CRM to deliver brilliant...

From our world to yours

Kerv Digital 2022 Wrap-Up

From our world to yours

Life @ Kerv Digital As A Recruitment & People Analytics Manager

From our world to yours

CX Translate Opens the Door to International Understanding in Cross-Border Contact Centres

From our world to yours

Cloud Confessions: Q&A with CTO on Communications Compliance

From our world to yours

Helping With Hackathon Fundamentals

From our world to yours

Kerv Digital & Microsoft Solutions Partner Designations

From our world to yours

Life at Kerv as a Billing & Operations Co-Ordinator

Have a question?

Leave your details and a member of the team will be in touch to help.
By pressing send, you agree to our Terms and Conditions and Privacy Policy.
This field is for validation purposes and should be left unchanged.