Notifications
Announcements
No record found.
var ReportSelections: Record "Report Selections"; TempReportSelections: Record "Report Selections" temporary; TempBlob: Codeunit "Temp Blob"; Base64Convert: Codeunit "Base64 Convert"; outStreamReport: OutStream; inStreamReport: InStream; ReportUsage: Enum "Report Selection Usage"; DocumentPrint: Codeunit "Document-Print"; SourceRecordRef: RecordRef; SalesHeader: Record "Sales Header"; DocumentBase64: Text; begin // If you already have a RecordRef, you can skip the next four lines. if not SalesHeader.FindFirst() then // For testing purposes, retrieving the first record of the Sales Header. // In your real scenario, replace this with the necessary conditions. exit; SalesHeader.SetRecFilter(); // Set the filter on SalesHeader to be used for the RecordRef. SourceRecordRef.GetTable(SalesHeader); // Assign the SalesHeader record to the SourceRecordRef. ReportUsage := DocumentPrint.GetSalesDocTypeUsage(SalesHeader); // Determine the report usage based on the document type of the Sales Header. ReportSelections.FindReportUsageForCust(ReportUsage, SalesHeader."No.", TempReportSelections); // Find the appropriate report selection for the customer based on the report usage and Sales Header number. // Store the result in a temporary Report Selections record (TempReportSelections). TempBlob.CreateOutStream(outStreamReport); // Create an output stream in the TempBlob to store the generated report. ReportSelections.SaveReportAsPDFInTempBlob( TempBlob, TempReportSelections."Report ID", SourceRecordRef, TempReportSelections."Custom Report Layout Code", ReportUsage ); // Save the selected report as a PDF into TempBlob using the specified report ID, // custom report layout, and report usage. TempBlob.CreateInStream(inStreamReport); // Create an input stream from the TempBlob to read the PDF report data. DocumentBase64 := Base64Convert.ToBase64(inStreamReport, false); // Convert the report data from the input stream to a Base64-encoded string // and assign it to the DocumentBase64 variable. end;
Hi, good day I hope this can help you, and give you some hints.
Create Base64 string of business central report - NAVwithNAV
How to Obtain Different PDF Reports of Sales Orders through Webservices - Ivan Singleton
Dynamics 365 Business Central: How to convert Image (item picture) to encoded text (Base64 String) via AL | Dynamics 365 Lab
Best Regards Gerardo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
OussamaSabbouh 2,092
YUN ZHU 663 Super User 2025 Season 2
Sumit Singh 515