With the upcoming 2025 Wave 1 release of Business Central, Microsoft introduces a long-awaited feature: previewing PDF attachments directly in the Web Client – no download required. It’s a small but impactful usability enhancement.
But let’s skip the basic feature walk-through (you’ll find plenty of that elsewhere) and get straight to the real-world implications and what you should actually be aware of before using this functionality in production.
📎 Only PDFs – Nothing Else (Yet)
As of now, this feature only works with PDF files. It does not support other commonly used file types like images, Word documents, Excel sheets, or anything else. If you attempt to preview a non-PDF file, you’re in for some tricky behavior – especially if you don’t handle it properly in AL code.
💣 Be Careful: It Can Crash the Web Client
The preview function
- File.ViewFromStream – for Business Central online
- File.View – for Business Central on-premises
returns a boolean, which gives the impression that you can easily check if it was successful – and in theory, you can.
But here’s the catch:
- If the file is not a PDF and doesn’t have a
.pdfextension, previewing it will throw an error and freeze the Web Client. The only way out: refresh the browser tab. - So yes, you need to check yourself before calling the preview function whether the file really is a PDF — don’t rely on the return value alone.
A simple file extension check before the preview call is your best bet for now.
So what’s the right way to handle this?
➡ Microsoft actually checks file types this way in the Document Attachment table:
internal procedure SupportedByFileViewer(): Boolean
begin
case Rec."File Type" of
Rec."File Type"::PDF:
exit(true);
Rec."File Type"::" ":
begin
if Rec."File Extension" <> '' then
exit(LowerCase(Rec."File Extension") = 'pdf');
exit(Lowercase(Rec.”File Name”).EndsWith(‘pdf’))
end;
else
exit(false);
end;
end;
This is a much more reliable approach than just checking the file name.
Pro tip: Use this or similar logic in your custom file handling to avoid application freezes and give users a smoother experience.
🧠 “Looks Like a PDF” ≠ Is a PDF
There’s another edge case worth mentioning:
If you have a non-PDF file (e.g., a Word doc or image) but the file name ends with .pdf, the system will try to preview it. This time, you’ll still get an error message, but at least the client won’t freeze. The user can close the preview dialog and continue working. Still, not ideal — but at least it’s survivable.
🪟 Preview Opens in the Same Tab – Not Always Practical
Another limitation: the preview always opens in the same browser tab. That means if users want to compare the document side-by-side with an order, shipment, or invoice, they’re out of luck — unless you offer a workaround.
➡ Here’s a small trick, which might solve the Problem:
If you have a Preview action on a page, use GetUrl and HYPERLINK to open a dedicated preview page in a new tab:
Hyperlink(GetUrl(ClientType::ChildSession, CompanyName, ObjectType::Page, Page::"Document Preview Card", Rec));
Then, on the Document Preview Card page, you can automatically trigger the preview logic like this:
trigger OnOpenPage()
var
TenantMedia: Record "Tenant Media";
FileContent: InStream;
FileName: Text[250];
begin
if TenantMedia.Get(Rec."File Content".MediaId()) then begin
TenantMedia.CalcFields(Content);
if TenantMedia.Content.HasValue() then begin
TenantMedia.Content.CreateInStream(FileContent);
FileName := Rec."File Name";
if SupportedByFileViewer() then
ViewFromStream(FileContent, FileName);
end;
end;
end;
This gives users the feel of viewing PDFs in parallel, like before. But it still might not be the most intuitive flow – and many users will still prefer to just download the file.
So don’t be surprised if this new feature doesn’t fully eliminate the need for downloading attachments – it just offers an additional option.
✅ TL;DR – Summary
- ✅ Nice addition, but only works for PDFs
- ❌ Calling preview on non-PDFs will crash the Web Client unless you pre-check the file extension
- ⚠️ Wrong extension can trick the system, but doesn’t crash
- 🔗 Preview opens in same tab, not always practical for user workflows
- 💡 Workarounds are possible, but downloading may still be the preferred option in many cases
Have you tested the feature already? How are you planning to use it in your projects? Let me know your thoughts – I’d love to hear how others are tackling the UX side of this.