bcquality/microsoft/knowledge/data-modeling/document-print-and-email-actions-call-report-selections-directly.bad.al
Michael Dieringer aad3991d9f Fix three merge-critical items from Jesper's 2026-09-29 review
- Barcode: drop the false claim that '*value*' is mismatched with the
  IDAutomation Code 39 font; '*' is a documented start/stop form and
  '(' / ')' an accepted alternative. Cue and article now route only
  independently provable validation/checksum/font-binding defects.
- Dispatch good samples (and matching bad samples) now pass a
  Sales Invoice Header with the S.Invoice usage, matching the record
  the selected report (1306 "Standard Sales - Invoice") expects.
- custom-document-dispatch rule made disjunctive: a hardcoded report
  or a hand-built email is each a bypass on its own; scoped to
  customer/vendor-facing documents. Bad fixture shows the hardcoded
  report alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:45:02 +02:00

45 lines
2 KiB
AL

page 50101 "Sample Posted Invoice Card"
{
PageType = Card;
SourceTable = "Sales Invoice Header";
ApplicationArea = All;
Editable = false;
actions
{
area(Processing)
{
action(EmailDocument)
{
ApplicationArea = All;
Caption = 'Email';
Image = Email;
trigger OnAction()
var
SalesInvoiceHeader: Record "Sales Invoice Header";
DocumentSendingProfile: Record "Document Sending Profile";
ReportDistributionMgt: Codeunit "Report Distribution Management";
begin
// WRONG: this is a plain, on-demand "Email" button, not
// part of a combined Post-and-Send action - but this
// loads the customer's ACTUAL assigned profile (or the
// tenant default, if none is assigned - the same lookup
// Sales-Post and Send performs) and calls Send on it, so
// the outcome now silently depends on that profile. A
// profile set up for Post-and-Send printing only (say,
// Printer = Yes, "E-Mail" = No) turns this button into a
// silent no-op, with no indication an unrelated setup
// field is why.
SalesInvoiceHeader := Rec;
CurrPage.SetSelectionFilter(SalesInvoiceHeader);
DocumentSendingProfile.GetDefaultForCustomer(Rec."Bill-to Customer No.", DocumentSendingProfile);
DocumentSendingProfile.Send(
"Report Selection Usage"::"S.Invoice".AsInteger(), SalesInvoiceHeader, Rec."No.",
Rec."Bill-to Customer No.", ReportDistributionMgt.GetFullDocumentTypeText(Rec),
SalesInvoiceHeader.FieldNo("Bill-to Customer No."), SalesInvoiceHeader.FieldNo("No."));
end;
}
}
}
}