RE: SavesAS Function & File Management in Business Central On-Prem (ver16)
Hi, The Report.SaveAsPdf method should be fine in the On-Pre version. It's a little weird.
Well, can the solution below give you some hints? Just using Report.SaveAs(Integer, Text, ReportFormat, var OutStream [, RecordRef) Method.
https://yzhums.com/wp-content/uploads/2022/01/CustomFilenameForReportExport.mp4
pageextension 50100 ZYSalesOrderExt extends "Sales Order List"
{
actions
{
addafter("Print Confirmation")
{
action(SaveConfirmationAsPdf)
{
Caption = 'Save Confirmation As Pdf';
ApplicationArea = All;
Image = Export;
Promoted = true;
PromotedCategory = Category8;
PromotedIsBig = true;
trigger OnAction()
var
TempBlob: Codeunit "Temp Blob";
FileManagement: Codeunit "File Management";
OStream: OutStream;
SalesHeader: Record "Sales Header";
RecRef: RecordRef;
begin
SalesHeader.Reset();
Clear(OStream);
CurrPage.SetSelectionFilter(SalesHeader);
RecRef.GetTable(SalesHeader);
TempBlob.CreateOutStream(OStream);
Report.SaveAs(Report::"Standard Sales - Order Conf.", '', ReportFormat::Pdf, OStream, RecRef);
FileManagement.BLOBExport(TempBlob, 'Sales Order_' UserId '_' Format(CurrentDateTime, 0, '') '.pdf', true);
end;
}
}
}
}
Hope this helps.
Thanks.
ZHU