[Event Request] codeunit 260 "Document-Mailing" OnBeforeFromReportSelectionUsage #27947
Open
Description
Describe the request
Can you add a event to be able to override the code that sets EmailScenario?
// >>>>>>>>>>>>
OnBeforeFromReportSelectionUsage(EmailScenario, IsHandled);
if not IsHandled then
// <<<<<<<<<<<<
if Enum::"Report Selection Usage".Ordinals().Contains(ReportUsage) then
EmailScenario := EmailScenarioMapping.FromReportSelectionUsage(Enum::"Report Selection Usage".FromInteger(ReportUsage));
EmailSentSuccesfully := TempEmailItem.Send(HideDialog, EmailScenario, Enqueue);
if EmailSentSuccesfully then
OnAfterEmailSentSuccesfully(TempEmailItem, PostedDocNo, ReportUsage);
The best solution we be to not replace EmailScenario if it is not default
// >>>>>>>>>>>>
if EmailScenario <> EmailScenario::Default then
// <<<<<<<<<<<<
if Enum::"Report Selection Usage".Ordinals().Contains(ReportUsage) then
EmailScenario := EmailScenarioMapping.FromReportSelectionUsage(Enum::"Report Selection Usage".FromInteger(ReportUsage));
EmailSentSuccesfully := TempEmailItem.Send(HideDialog, EmailScenario, Enqueue);
if EmailSentSuccesfully then
OnAfterEmailSentSuccesfully(TempEmailItem, PostedDocNo, ReportUsage);
Additional context
When replacing EmailScenario in event OnBeforeSendEmail, it is set back to default because of the mentioned code.
Internal work item: AB#562595