Skip to content

[Bug]: Report layout name from selected report usage is ignored in GetPdfReportForCust/ForVend/ForTable (TempBlob overloads) #9875

Description

@astaric

Describe the issue

The Temp Blob overloads of GetPdfReportForCust, GetPdfReportForVend, and GetPdfReportForTable in table 77 "Report Selections" call SaveReportAsPDFInTempBlob on the current record instance (Rec) instead of on the TempBodyReportSelections variable that was just populated by FindReportUsageFor....

Inside SaveReportAsPDFInTempBlob, the layout is resolved from Rec:

if Rec."Report Layout Name" <> '' then
    ReportLayoutSelectionLocal.SetTempLayoutSelectedName(Rec."Report Layout Name", Rec."Report Layout AppID")
else
    ReportLayoutSelectionLocal.SetTempLayoutSelected(LayoutCode);

Because the method is not invoked on TempBodyReportSelections, Rec."Report Layout Name" / Rec."Report Layout AppID" do not reflect the resolved report-usage row. Only "Report ID" and "Custom Report Layout Code" are passed as parameters, so the modern report layout name/AppID from the correct report selection is silently ignored, and the PDF may be generated with the wrong (or default) layout.

The correct pattern is used elsewhere in the same table, where the method is invoked on the temporary record so that Rec inside SaveReportAsPDFInTempBlob becomes the resolved row — e.g. SendToDiskForCust, SendToZipForCust, SaveAsDocumentAttachment, and SendEmailDirectly all call TempReportSelections.SaveReportAsPDFInTempBlob(...). PrintDocumentsWithCheckDialogCommon similarly reads TempReportSelections."Report Layout Name".

Affected code
GetPdfReportForCust(var TempBlob: Codeunit "Temp Blob"; ...)
GetPdfReportForVend(var TempBlob: Codeunit "Temp Blob"; ...)
GetPdfReportForTable(var TempBlob: Codeunit "Temp Blob"; ...)
in ReportSelections.Table.al

Example (GetPdfReportForCust):

FindReportUsageForCust(ReportUsage, CustNo, TempBodyReportSelections);
SaveReportAsPDFInTempBlob(TempBlob, TempBodyReportSelections."Report ID", RecordVariant, TempBodyReportSelections."Custom Report Layout Code", ReportUsage);

Note: the Text[250] (file path) overloads are not affected, since they call SaveReportAsPDF, which does not read "Report Layout Name".

Expected behavior

The report layout name/AppID configured on the resolved report selection for the given usage should be honored when generating the PDF, consistent with SendToDiskForCust and the printing path.

Steps to reproduce

  1. Configure a Report Selection entry for a customer-facing usage (e.g. Sales Invoice) with a modern report layout selected via "Report Layout Name" (not a custom RDLC/Word layout code).
  2. Generate the PDF through a code path that calls the TempBlob overload of GetPdfReportForCust (rather than the print/send-to-disk path).
  3. Observe that the generated PDF does not use the configured report layout; the default layout is used instead.

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    IntegrationGitHub request for Integration area

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions