Skip to content

[Event Request] codeunit 260 "Document-Mailing" OnBeforeFromReportSelectionUsage #27947

Open
@auzhhv

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

Metadata

Assignees

No one assigned

    Labels

    IntegrationGitHub request for Integration areaevent-requestRequest for adding an event

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions