Why do you need this change?
We need to bypass the standard Microsoft logic in this procedure because we have a separate feature that already handles the assignment of the VAT Registration No. and the relevant posting groups.
Without an IsHandled pattern, the Microsoft logic is always executed and may overwrite or conflict with the values set by our own feature.
Describe the request
Please add an OnBeforeUpdateSetupOnBillToCustomerChangeInSalesHeader integration event before calling AltCustVATRegFacade.UpdateSetupOnBillToCustomerChangeInSalesHeader(Rec, xRec, BillToCustomer) in procedure SetBillToCustomerAddressFieldsFromCustomer.
The event should provide an IsHandled parameter so subscribers can skip the mentioned call when they handle the logic themselves.
Requested change:
(from)
procedure SetBillToCustomerAddressFieldsFromCustomer(var BillToCustomer: Record Customer)
var
IsHandled: Boolean
begin
[...]
if "Document Type" in ["Document Type"::"Credit Memo", "Document Type"::"Return Order"] then begin
"Payment Method Code" := '';
if PaymentTerms.Get("Payment Terms Code") then
if PaymentTerms."Calc. Pmt. Disc. on Cr. Memos" then
"Payment Method Code" := BillToCustomer."Payment Method Code"
end else
"Payment Method Code" := BillToCustomer."Payment Method Code";
AltCustVATRegFacade.UpdateSetupOnBillToCustomerChangeInSalesHeader(Rec, xRec, BillToCustomer);
[...]
end;
(to)
procedure SetBillToCustomerAddressFieldsFromCustomer(var BillToCustomer: Record Customer)
var
IsHandled: Boolean
begin
[...]
if "Document Type" in ["Document Type"::"Credit Memo", "Document Type"::"Return Order"] then begin
"Payment Method Code" := '';
if PaymentTerms.Get("Payment Terms Code") then
if PaymentTerms."Calc. Pmt. Disc. on Cr. Memos" then
"Payment Method Code" := BillToCustomer."Payment Method Code"
end else
"Payment Method Code" := BillToCustomer."Payment Method Code";
>>>
IsHandled := false;
OnBeforeUpdateSetupOnBillToCustomerChangeInSalesHeader(Rec, BillToCustomer, IsHandled);
if not IsHandled then
AltCustVATRegFacade.UpdateSetupOnBillToCustomerChangeInSalesHeader(Rec, xRec, BillToCustomer);
<<<
[...]
end;
>>>
[IntegrationEvent(false, false)]
local procedure OnBeforeUpdateSetupOnBillToCustomerChangeInSalesHeader(var SalesHeader: Record "Sales Header"; BillToCustomer: Record Customer; var IsHandled: Boolean)
begin
end;
<<<
Additional (mentioned by Triage Agent)
alternatives_evaluated:
I could not find a suitable alternative. There are already three events in this procedure: two near the beginning and one at the end. However, I do not want to subscribe to one of the earlier events and handle the whole procedure myself, because the standard logic is fine for my scenario. The only part I need to skip is the call to AltCustVATRegFacade.UpdateSetupOnBillToCustomerChangeInSalesHeader.
performance_considerations:
The new event would be raised at the same frequency as the other events in this procedure. It would be raised once per procedure execution, unless another subscriber handles OnBeforeSetBillToCustomerAddressFieldsFromCustomer and sets IsHandled to true.
data_sensitivity_review:
I can only assess this from the available context, but I do not expect any additional sensitive data to be exposed. All proposed parameters are already passed to other events in the same procedure, such as OnBeforeSetBillToCustomerAddressFieldsFromCustomer, OnSetBillToCustomerAddressFieldsFromCustomerOnAfterAssignBillToCustomerAddress, and OnAfterSetFieldsBilltoCustomer.
multi_extension_interaction:
There is a potential risk of interaction between multiple extensions (although this seems to be a general concern with events that use the IsHandled pattern or not? 😕). In an unfavorable scenario, another subscriber could reset IsHandled after my subscriber has set it to true.
Internal work item: AB#641535
Why do you need this change?
We need to bypass the standard Microsoft logic in this procedure because we have a separate feature that already handles the assignment of the VAT Registration No. and the relevant posting groups.
Without an IsHandled pattern, the Microsoft logic is always executed and may overwrite or conflict with the values set by our own feature.
Describe the request
Please add an OnBeforeUpdateSetupOnBillToCustomerChangeInSalesHeader integration event before calling AltCustVATRegFacade.UpdateSetupOnBillToCustomerChangeInSalesHeader(Rec, xRec, BillToCustomer) in procedure SetBillToCustomerAddressFieldsFromCustomer.
The event should provide an IsHandled parameter so subscribers can skip the mentioned call when they handle the logic themselves.
Requested change:
(from)
(to)
Additional (mentioned by Triage Agent)
alternatives_evaluated:
I could not find a suitable alternative. There are already three events in this procedure: two near the beginning and one at the end. However, I do not want to subscribe to one of the earlier events and handle the whole procedure myself, because the standard logic is fine for my scenario. The only part I need to skip is the call to AltCustVATRegFacade.UpdateSetupOnBillToCustomerChangeInSalesHeader.
performance_considerations:
The new event would be raised at the same frequency as the other events in this procedure. It would be raised once per procedure execution, unless another subscriber handles OnBeforeSetBillToCustomerAddressFieldsFromCustomer and sets IsHandled to true.
data_sensitivity_review:
I can only assess this from the available context, but I do not expect any additional sensitive data to be exposed. All proposed parameters are already passed to other events in the same procedure, such as OnBeforeSetBillToCustomerAddressFieldsFromCustomer, OnSetBillToCustomerAddressFieldsFromCustomerOnAfterAssignBillToCustomerAddress, and OnAfterSetFieldsBilltoCustomer.
multi_extension_interaction:
There is a potential risk of interaction between multiple extensions (although this seems to be a general concern with events that use the IsHandled pattern or not? 😕). In an unfavorable scenario, another subscriber could reset IsHandled after my subscriber has set it to true.
Internal work item: AB#641535