bcquality/microsoft/knowledge/data-modeling/document-print-and-email-actions-call-report-selections-directly.bad.al
Michael Dieringer 83f041b662 Add 5 AL/BC patterns: document distribution (Report Selections, Document Sending Profile, Find Entries, TransferFields)
Five rules about Business Central's document distribution architecture,
verified against BCApps source and Microsoft Learn.

- custom-document-dispatch-must-not-bypass-report-selections
- document-print-and-email-actions-call-report-selections-directly
- extend-find-entries-navigate-for-new-document-types
- extend-report-selection-usage-for-new-document-types
- transferfields-mirrored-fields-must-match-type-and-length

Wired into al-data-modeling-review.md's worklist cues. Added a
disambiguation note on the TransferFields article distinguishing it from
the existing transferfields-skip-type-mismatch-can-drop-data.md
(type-mismatch skipping vs. length mismatch, which SkipFieldsNotMatchingType
does not affect).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-10 07:44:17 +02:00

35 lines
1.3 KiB
AL

page 50101 "Sample Settlement Document Card"
{
PageType = Card;
SourceTable = Customer;
ApplicationArea = All;
actions
{
area(Processing)
{
action(EmailDocument)
{
ApplicationArea = All;
Caption = 'Email';
Image = Email;
trigger OnAction()
var
DocumentSendingProfile: Record "Document Sending Profile";
begin
// WRONG: this is a plain, on-demand "Email" button, not
// part of a combined Post-and-Send action - but routing
// it through Document Sending Profile means the outcome
// now silently depends on this customer's assigned
// profile. If that profile's "E-Mail" option is No, the
// user sees nothing happen after clicking Email, with no
// indication that an unrelated setup field is why.
DocumentSendingProfile.Send(
"Report Selection Usage"::"S.Invoice".AsInteger(), Rec, Rec."No.", Rec."No.",
Rec.Name, Rec.FieldNo("No."), Rec.FieldNo("No."));
end;
}
}
}
}