Dynamics 365 Business Central: parsing a CSV file using CSV Buffer

A question received today was the following: is it possible from my extension in Dynamics 365 Business Central asking a user to select a local CSV file, load it and then managing the content accordingly to my business needs using CSV Buffer table?

In standard NAV code (C/AL) you can use CSV Buffer table to load a CSV file (without using an XMLPort) and then parsing its content line by line. You can load a CSV file by using the following C/AL code:


And what about AL code? Can I use CSV Buffer in my extension for Dynamics 365 Business Central (SaaS)? The answer is yes, but the way you read the file is different. If you try to use the LoadData method, this is the result:


Here you’re in the cloud and you need to use Streams for accessing files. This is the code that works in a cloud Dynamics 365 Business Central environment:


The key here is to create an InStream object, reading the CSV file to the InStream object and then call the LoadDataFromStream method of the CSV Buffer table. Then you can parse the CSV content exactly like on the old C/AL code.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.