With the release of Business Central 26.3, it’s now possible to attach or embed files directly within the system.
This is a feature I’ve been hoping for for a long time, as it opens up a lot of exciting possibilities. In this quick guide, I’ll show you how to use it effectively.

Let’s start with the essentials.
Microsoft has introduced a new Codeunit that makes it incredibly easy to attach, embed, or protect documents—streamlining the entire process.
The Codeunit in question is codeunit 3110 “PDF Document”, which is part of the System Application.


In our example, we’ll extend the Standard Sales – Invoice Report and append a document that will be rendered together with the invoice.
This allows us to include additional information such as terms and conditions, product guides, or promotional content directly within the final PDF output.

OnPreReport for
report 1306 “Standard Sales – Invoice”

For this example, I created a simple Media field where I uploaded a sample PDF from Microsoft’s BCTechSamples for Customer 10000.
Since the procedure we’re using expects an InStream as a parameter, we need to convert the media content accordingly before appending it to the report.

OnPreRendering Trigger
OnPreRendering

Now we can already modify our payload and check the Results.

Report
Default Invoice
Merged PDF Document
Our Attached PDF which we merged in the rendering.

As we can see, it really is child’s play play, since the Codeunit from Microsoft does all the heavy lifting.

So far, so good! Now you might be wondering how to embed additional content—like PDFs, images, or even an XML file, such as one required for an e-invoice. Or maybe you are more interested in protecting your document ?

Embedding other file types is just as easy, but there’s a little limitation at the moment.
It seems like the procedure to Embed a file via an InStream is currently still missing.
But you don’t have to worry I have already requested said procedure and it should be released in the near future.

Regardless I still want to showcase you how you would embed files via the OnPreRendering.

Attach and Embed

Here we simply modified the OnPreReport as well to Embed the pdf file, just like we Appended it in the rendering.

You have to keep in mind that “NotYetReleased” would be “PDFDocument”, since the procedure AddAttachment is supposed to be included in codeunit 3110 as well.

Here’s another example where we generate an XML file and embed it into the printed document—just like you would for an e-invoice.

OnPreRendering trigger
Result of Embed
Result of Embeding

Final words: Microsoft provided us with this amazing new feature and I can already imagine multiple use cases for it.

You just have to keep in mind that there are limitations depending on how you started the rendering process for your report.

Report action overview
5 3 votes
Post Rating
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments