Skip to content

[Event Change Request] table 77 "Report Selections" Event OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage #30386

Description

@ZepposBE

Why do you need this change?

In a previous request by @fvet, a begin/end was requested, because it makes the event useless otherwise.
Even though this request was completed: #28346

The code still lacks the "begin" and "end" that is needed to prevent an exit(false); from happening when it shouldn't.
There might have been a mix up with the 2x GetEmailBodyForVend procedures, but the newest one is lacking the requered begin/end.

Describe the request

We need the mentioned begin/end as in the code below in order for the event to be usable correctly.
Otherwise we set the EmailBodyUsageFound to true, but the exit(false) is preventing further use of the data we've set up on the event: OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage, but in the newest version of the procedure 'GetEmailBodyForVend'.

Code with the additions:

procedure GetEmailBodyForVend(var EmailBody: Codeunit "Temp Blob"; ReportUsage: Enum "Report Selection Usage"; RecordVariant: Variant;
                                                     VendorNo: Code[20]; var VendorEmailAddress: Text[250]) Result: Boolean
    var
        TempBodyReportSelections: Record "Report Selections" temporary;
        FoundVendorEmailAddress: Text[250];
        IsHandled, EmailBodyUsageFound : Boolean;
#if not CLEAN27
        ServerEmailBodyFileCreated: Boolean;
        ServerEmailBodyFilePath: Text[250];
#endif
    begin
        Clear(EmailBody);

        IsHandled := false;
        OnBeforeGetEmailBodyVendor(
          ReportUsage.AsInteger(), RecordVariant, TempBodyReportSelections, VendorNo, VendorEmailAddress, IsHandled);
        if IsHandled then
            exit;

        VendorEmailAddress := GetEmailAddressForVend(VendorNo, RecordVariant, ReportUsage);

        if not FindEmailBodyUsageForVend(ReportUsage, VendorNo, TempBodyReportSelections) then begin
            IsHandled := false;
            EmailBodyUsageFound := false;
            OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage(
              ReportUsage.AsInteger(), RecordVariant, VendorNo, TempBodyReportSelections, IsHandled, EmailBodyUsageFound);
            if not EmailBodyUsageFound then begin//<----------Add this
                if IsHandled then
                    exit(true);
                exit(false);// --> wrong exit without the begin/end
            end;//<----------Add this
        end;

        if TempBodyReportSelections."Email Body Layout Code" <> '' then
            SaveReportAsHTML(TempBodyReportSelections."Report ID", RecordVariant, TempBodyReportSelections."Email Body Layout Code", ReportUsage, EmailBody)
        else
            SaveReportAsHTML(TempBodyReportSelections."Report ID", RecordVariant, TempBodyReportSelections."Email Body Layout Name", TempBodyReportSelections."Email Body Layout AppID", ReportUsage, EmailBody);

        FoundVendorEmailAddress :=
          FindEmailAddressForEmailLayout(TempBodyReportSelections."Email Body Layout Code", VendorNo, ReportUsage, Database::Vendor);
        if FoundVendorEmailAddress <> '' then
            VendorEmailAddress := FoundVendorEmailAddress;

This change will prevent the code from exiting when we have set "EmailBodyUsageFound" to true.

Thanks in advance!

Edit: Adding the information requested by github actions:

Alternatives evaluated: Explain which existing events or extensibility patterns were considered and why they are insufficient for this scenario. --> OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage was added, but there's a bug/flaw in the code that is ran after the event. Preventing the correct behavior.
Performance considerations: Describe the expected execution frequency and any anticipated performance impact. --> None, the impact on performance is not relevant here, we just need a fix so the code can function properly.
Data sensitivity review: Confirm whether this change would expose any sensitive data. --> No, only a mising begin/end are to be added, so no extra data is going to be exposed.
Multi-extension interaction considerations: Explain how conflicts or interactions with other extensions should be handled. --> By fixing the issue as suggested extensions will be able to use the event as it was intended.
Internal work item: AB#644837

Metadata

Metadata

Assignees

No one assigned

    Labels

    IntegrationGitHub request for Integration areaextensibility-enhancementNew feature or request related to extensibility

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions