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

You might also be interested in

From our world to yours

The Role of AI in Government: Driving Operational Costs Down Whilst Improving...

From our world to yours

Sustainability, Social Impact and Technology Procurement in the Transport Sector  

From our world to yours

The Kerv and Genesys Partnership goes from Strength to Strength

From our world to yours

How BPOs can automate with care

From our world to yours

Focusing on employee engagement and performance matters

From our world to yours

Compliance Cloud: Overview & demonstrations

From our world to yours

Life at Kerv as a People Partner

From our world to yours

Unveiling The Latest Advancements: Microsoft Dynamics 365 – Release Wave 2

From our world to yours

4 Steps To Building A Compliance Solution

From our world to yours

Kerv is officially one of the UK’s Best Workplaces in Tech!

From our world to yours

Supporting Supporters: How Nonprofits Can Plan For The Future

From our world to yours

GoodShape Raises the Bar for Member Experience, Call Quality, & Compliance

From our world to yours

Qualitas: How small businesses coming together can aid GP practices

From our world to yours

Capacity vs Capability

From our world to yours

CV Library: How strong leadership focused on IT can be a vital...

From our world to yours

Microsoft Teams Telephony

From our world to yours

Voxivo4Teams Cloud Voice Solution

From our world to yours

Microsoft Teams Rooms

From our world to yours

What is Azure Arc?

From our world to yours

Delivering a platform to underpin Fotech’s rapid growth plans

From our world to yours

What is Shadow IT?

From our world to yours

The Low Code/No Code Canvas

From our world to yours

How Buckinghamshire NHS Trust sped up their service

From our world to yours

Capitalise on the Cloud Opportunity

From our world to yours

Lightspeed Broadband – from funding to first customer in 7 months!

Have a question?

Leave your details and a member of the team will be in touch to help.

"*" indicates required fields

By pressing send, you agree to our Terms and Conditions and Privacy Policy.
This field is for validation purposes and should be left unchanged.