microsoft / microsoft/BCApps

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

Open Beginner friendly
#9,875 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team: Integrations
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ReportSelections.Table.al with GetPdfReportForCust, GetPdfReportForVend, and GetPdfReportForTable and trace how each TempBlob overload resolves report usage. Compare their calls with SendToDiskForCust, SendToZipForCust, SaveAsDocumentAttachment, and SendEmailDirectly. Done means PDFs generated through all three TempBlob overloads honor the resolved Report Layout Name and AppID.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.