blogs & Things

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:

 

More blogs & Things

More blogs & Things


James Crossland in NonProfit

AI + Automation: Reducing Donor Churn & Maintaining Sponsor Interest

Churn management is a vital element of any marketing strategy, and the NonProfit sector is no exception. Knowing what to track and having a joined up view of all your donations data is vital for getting this right, and also opens the door to building innovative data-driven campaigns.   At our recent DataScience and Transformation in Charities […]


James Crossland in NonProfit

Dynamics 365 In NonProfit’s

Charities have unique funding concerns, and an obligation to spend as much as possible on their chosen cause. However, an investment in technology can offer ROI in the form of more than just improved fundraising. Dynamics 365 can help rework complex business processes, ensure compliance with stringent safeguarding and financial regulations, as well as consolidate […]


James Crossland in Tech

8 Ways Your Business Can Increase Turnover With Big Data

Understand how Big Data and Data Science can transform your business…   Big Data is the phrase that’s used to categorise any data that’s too large, complex, cumbersome or complicated to be managed and processed by conventional technology. To put that into a relatable context; being able to recommend your customers content, products or offers based […]


James Crossland in NonProfit

How To Reduce Donor Churn In NonProfits

Reducing Donor Churn doesn’t have to be a big task but does need to be a fundamental part of a NonProfit’s day to day processes   What Is Donor Churn? Donor Churn is the likelihood of an individual stopping their donations to a charitable cause for a variety of different reasons resulting in the non-profit organisation […]


James Crossland in Tech

Agile: Cutting Costs, Improving Quality & Accessing Talent

After using Agile to develop software products for several years, we thought we’d share the challenges we encountered at the start, what we did to change and the results we saw (which were ultimately uplifts in quality and efficiency)…   My development team has been using Agile to develop software product since 2007. Personally, I’ve seen many […]


James Crossland in Tech

UI VS UX

What’s the difference between UI and UX?   Simply put UI (or User Interface) are the pages, screens, buttons, icons and any other visual aspects of a website or App that let you interact with it… or to expand on that into the non-virtual world… UI is how you experience using something – For instance in opening a fridge, […]