[Event Change Request] table 77 "Report Selections" Event OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage
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: https://github.com/microsoft/ALAppExtensions/issues/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
Hi @ZepposBE,
Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.
Missing Information:
- Alternatives evaluated: Explain which existing events or extensibility patterns were considered and why they are insufficient for this scenario.
- Performance considerations: Describe the expected execution frequency and any anticipated performance impact.
- Data sensitivity review: Confirm whether this change would expose any sensitive data.
- Multi-extension interaction considerations: Explain how conflicts or interactions with other extensions should be handled.
Please update the issue with the missing details. We'll automatically re-analyze once updated.
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Not accurate? Reply with
/not-accurate(optional: add a short explanation). Your feedback improves future responses.
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.
✅ Analysis complete - ready for further processing
Implementation:
Update GetEmailBodyForVend so the procedure only exits when EmailBodyUsageFound remains false after OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage.
Current code:
if not FindEmailBodyUsageForVend(ReportUsage, VendorNo, TempBodyReportSelections) then begin
IsHandled := false;
EmailBodyUsageFound := false;
OnGetEmailBodyVendorTextOnAfterNotFindEmailBodyUsage(
ReportUsage.AsInteger(), RecordVariant, VendorNo, TempBodyReportSelections, IsHandled, EmailBodyUsageFound);
if IsHandled then
exit(true);
exit(false);
end;
Proposed change:
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
if IsHandled then
exit(true);
exit(false);
end;
end;
File: ReportSelections.Table.al
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Not accurate? Reply with
/not-accurate(optional: add a short explanation). Your feedback improves future responses.
Please recreate your request in BCApps.