Hi, Readers.
The public preview for Dynamics 365 Business Central 2025 release wave 1 (BC26) is available. Learn more: Link.
I will continue to test and share some new features that I hope will be helpful.
Preview PDF attachments directly in web client:
Business value:
https://learn.microsoft.com/en-us/dynamics365/release-plan/2024wave2/smb/dynamics365-business-central/use-default-quantity-1-accounts-documents?wt.mc_id=DX-MVP-5004336
By providing you a smooth and easy way to work with attachments, report outputs, or incoming documents, you remain productive and in the context of your work, which saves time and effort.
This feature lets you open PDF attachments directly in the Business Central web client without downloading them first. Files are shown in preview mode in a specialized viewer experience, similar to the print preview feature, and you can always download a PDF file from there.
This feature is now used in various areas of Business Central, such as document attachments and incoming documents.



Test video:
This feature works automatically across all areas of Business Central, including ISV code. However, it requires an uptake from extension developers because two new AL methods have been added to capture this new behavior, following the pattern of the File.Download method:
- File.ViewFromStream – for Business Central online
- File.View – for Business Central on-premises
This is also mentioned in the AL Language extension changelog.
Preview support in File: Two new methods to open and view a file on the client.
[Ok :=] File.ViewFromStream(Stream: InStream, FileName: String [, AllowDownloadAndPrint: Boolean]);
[Ok :=] File.View(FilePath: String [, AllowDownloadAndPrint: Boolean]);

Let me make a simple customization, preview selected Posted Sales Invoice directly in web client.

In the past, if we wanted to preview the invoice, we had to print it first and then click preview. With this function, we can preview it directly.

First let’s look at the standard logic on page 1173 “Document Attachment Details”



Here is my simple logic.


Looks good.

Test video:
Great. Give it a try!!!😁
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
pageextension 50115 PostedSalesInvoicesExt extends "Posted Sales Invoices"
{
actions
{
addafter("&Invoice")
{
action(OpenSelectedInvoiceInFileViewer)
{
ApplicationArea = All;
Caption = 'View Selected Invoice';
Image = View;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
var
ReportSelection: Record "Report Selections";
SalesInvHeader: Record "Sales Invoice Header";
TempReportSelections: Record "Report Selections" temporary;
TempBlob: Codeunit "Temp Blob";
PdfFileName: Text[50];
InS: InStream;
begin
SalesInvHeader.Reset();
CurrPage.SetSelectionFilter(SalesInvHeader);
if SalesInvHeader.FindFirst() then begin
SalesInvHeader.SetRecFilter();
ReportSelection.FindReportUsageForCust(Enum::"Report Selection Usage"::"S.Invoice", SalesInvHeader."Bill-to Customer No.", TempReportSelections);
Clear(TempBlob);
TempReportSelections.SaveReportAsPDFInTempBlob(TempBlob, TempReportSelections."Report ID", SalesInvHeader, TempReportSelections."Custom Report Layout Code", Enum::"Report Selection Usage"::"S.Invoice");
TempBlob.CreateInStream(InS);
PdfFileName := Format(SalesInvHeader."No." + '.pdf');
File.ViewFromStream(InS, PdfFileName + '.' + 'pdf', true);
end;
end;
}
}
}
}
2. Dynamics 365 Business Central: How to preview Base64 string image within BC (Base64 Image Viewer)
END
Hope this will help.
Thanks for reading.
ZHU
コメント