Dynamics 365 Business Central: previewing a file from AL.

With Dynamics 365 Business Central 2025 Wave 1 release (version 26) and the new AL Language extension version 15, it will be possible to preview a file directly in the web client (no need to use control add-ins anymore) without downloading it first.

Doing that is very easy. The new runtime 15 adds the following method to the File object:

File.ViewFromStream(Stream: InStream, FileName: String [, AllowDownloadAndPrint: Boolean]);

With the below code, you can read a file (for example a PDF) and preview it in the client:

This is the PDF rendered in preview mode in the client. Please note that you can also enable or disable the possibility to download and print it:

If the loaded file is not supported for previewing, an error message will be displayed:

Starting from Dynamics 365 Business Central version, this feature is used in various areas like document attachments and incoming documents to automatically preview an uploaded document:

Also a new method is available for Dynamics 365 Business Central on-premises:

File.View(FilePath: String [, AllowDownloadAndPrint: Boolean]);

but who cares about non SaaS-compliant code, isn’t it? 😜

2 Comments

  1. Hi Stefano, thanks for the post.

    I have been playing with BC26 and have not noticed this in standard BC preview. Have you seen it in use in standard BC preview we can play with?

    Thank you for all your efforts!
    Kris

    Like

Leave a reply to demiliani Cancel reply

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