Why do you need this change?
Event Placement in trigger OnNewRecord:
trigger OnNewRecord(BelowxRec: Boolean)
var
IsHandled: Boolean;
begin
xRec.Init();
IsHandled := false;
OnBeforeSetResponsibilityCenterOnNewRecord(Rec, IsHandled); // new event
if not IsHandled then
Rec."Responsibility Center" := UserMgt.GetSalesFilter();
if (not DocNoVisible) and (Rec."No." = '') then
Rec.SetSellToCustomerFromFilter();
Rec.SetDefaultPaymentServices();
SetControlAppearance();
UpdateShipToBillToGroupVisibility();
end;
Business Justification:
OnNewRecord assigns "Responsibility Center" from UserMgt.GetSalesFilter() for every new Sales Quote. In some business configurations the Responsibility Center should not default from the user's sales filter but should instead be determined from the customer selected on the document. Because the RC field's OnValidate trigger in the Sales Header table cascades changes to other fields, extensions that need to suppress or replace the default assignment must be able to do so before the assignment occurs, to avoid leaving the record in an inconsistent intermediate state.
A page extension OnNewRecord trigger runs after the base page trigger. By the time it fires, the RC has already been assigned. Resetting it via direct assignment bypasses the field's validation logic, which may produce inconsistencies if BC's internal initialization evolves to use Validate() instead of direct assignment.
Alternatives Evaluated:
- Page extension OnNewRecord with direct reset: Runs after the base trigger. The reset bypasses field validation. Fragile against future changes to whether the standard uses direct assignment or Validate().
Justification for IsHandled:
The IsHandled pattern is required because some partners must fully bypass the standard assignment of "Responsibility Center" on new records to implement custom initialization logic. Without IsHandled, the standard code would always run, making it impossible to prevent unwanted assignments or side effects. No alternative approach (such as a standard event without IsHandled or a page extension trigger) can achieve this.
Performance Considerations:
The OnNewRecord trigger is executed each time a new sales quote is created, which is a common operation but not performance-critical. The IsHandled pattern is already used in similar events on sales documents, and the performance impact is negligible since the event is only checked once per new record.
Data Sensitivity Review:
No sensitive data is exposed by this event. The parameters (SalesHeader, IsHandled) are already used in other event publishers on the same object.
Multi-Extension Interaction:
Standard IsHandled pattern. SalesHeader passed as var to allow extensions to set an alternative RC value rather than just suppressing.
Describe the request
[IntegrationEvent(false, false)]
local procedure OnBeforeSetResponsibilityCenterOnNewRecord(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)
begin
end;
Why do you need this change?
Event Placement in trigger OnNewRecord:
Business Justification:
OnNewRecord assigns "Responsibility Center" from UserMgt.GetSalesFilter() for every new Sales Quote. In some business configurations the Responsibility Center should not default from the user's sales filter but should instead be determined from the customer selected on the document. Because the RC field's OnValidate trigger in the Sales Header table cascades changes to other fields, extensions that need to suppress or replace the default assignment must be able to do so before the assignment occurs, to avoid leaving the record in an inconsistent intermediate state.
A page extension OnNewRecord trigger runs after the base page trigger. By the time it fires, the RC has already been assigned. Resetting it via direct assignment bypasses the field's validation logic, which may produce inconsistencies if BC's internal initialization evolves to use Validate() instead of direct assignment.
Alternatives Evaluated:
Justification for IsHandled:
The IsHandled pattern is required because some partners must fully bypass the standard assignment of "Responsibility Center" on new records to implement custom initialization logic. Without IsHandled, the standard code would always run, making it impossible to prevent unwanted assignments or side effects. No alternative approach (such as a standard event without IsHandled or a page extension trigger) can achieve this.
Performance Considerations:
The OnNewRecord trigger is executed each time a new sales quote is created, which is a common operation but not performance-critical. The IsHandled pattern is already used in similar events on sales documents, and the performance impact is negligible since the event is only checked once per new record.
Data Sensitivity Review:
No sensitive data is exposed by this event. The parameters (SalesHeader, IsHandled) are already used in other event publishers on the same object.
Multi-Extension Interaction:
Standard IsHandled pattern. SalesHeader passed as var to allow extensions to set an alternative RC value rather than just suppressing.
Describe the request
[IntegrationEvent(false, false)]
local procedure OnBeforeSetResponsibilityCenterOnNewRecord(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)
begin
end;