Why do you need this change?
We need to inject handling for custom document type inside the case block of ValidateDocNo in Report 292 "Copy Sales Document". The standard code evaluates FromDocType through a fixed case statement and calls FromSalesHeader.Get(...) accordingly, but there is no extensibility hook before this block to allow extensions to handle additional document type or skip the standard resolution entirely.
All subsequent logic in ValidateDocNo, including IncludeHeader evaluation, ValidateIncludeHeader, and OnAfterValidateIncludeHeader, depends on FromSalesHeader being correctly populated by thecaseblock. If a custom document type falls through the case statement unhandled, FromSalesHeader will remain empty and all downstream logic will produce incorrect results.
OnBeforeValidateIncludeHeader and OnAfterValidateIncludeHeader both fire after the case block has already executed, making them too late to inject custom document type handling or correct FromSalesHeader. No event currently exists before the case FromDocType of block in ValidateDocNo.
Describe the request
Add an integration event OnBeforeValidateDocNo in ValidateDocNo of Report 292 "Copy Sales Document" before thecase FromDocType ofblock, with IsHandled support to allow subscribers to handle custom document types and skip the standard case evaluation entirely.
local procedure ValidateDocNo()
var
FromDocType2: Enum "Sales Document Type From";
IsHandled: Boolean;
begin
if FromDocNo = '' then begin
FromSalesHeader.Init();
FromDocNoOccurrence := 0;
FromDocVersionNo := 0;
end else
if FromSalesHeader."No." = '' then begin
FromSalesHeader.Init();
IsHandled := false;
OnBeforeValidateDocNo(FromDocType, FromDocNo, FromSalesHeader, SalesHeader, IsHandled);
if not IsHandled then
case FromDocType of
FromDocType::Quote,
FromDocType::Order,
...
end;
end;
...
end;
Event Signature:
[IntegrationEvent(false, false)]
local procedure OnBeforeValidateDocNo(
FromDocType: Enum "Sales Document Type From";
FromDocNo: Code[20];
var FromSalesHeader: Record "Sales Header";
SalesHeader: Record "Sales Header";
var IsHandled: Boolean)
begin
end;
Alternatives evaluated:
OnBeforeValidateIncludeHeader and OnAfterValidateIncludeHeader both fire after the case block has completed, so subscribers there cannot inject handling for unrecognized document types or correct FromSalesHeader. The available events are scoped to individual existing document type branches and cannot be reached for custom document types.
Why do you need this change?
We need to inject handling for custom document type inside the case block of
ValidateDocNoin Report 292 "Copy Sales Document". The standard code evaluatesFromDocTypethrough a fixedcasestatement and callsFromSalesHeader.Get(...)accordingly, but there is no extensibility hook before this block to allow extensions to handle additional document type or skip the standard resolution entirely.All subsequent logic in
ValidateDocNo, includingIncludeHeaderevaluation,ValidateIncludeHeader, andOnAfterValidateIncludeHeader, depends onFromSalesHeaderbeing correctly populated by thecaseblock. If a custom document type falls through thecasestatement unhandled,FromSalesHeaderwill remain empty and all downstream logic will produce incorrect results.OnBeforeValidateIncludeHeaderandOnAfterValidateIncludeHeaderboth fire after the case block has already executed, making them too late to inject custom document type handling or correctFromSalesHeader. No event currently exists before thecase FromDocType ofblock inValidateDocNo.Describe the request
Add an integration event
OnBeforeValidateDocNoinValidateDocNoof Report 292 "Copy Sales Document" before thecase FromDocType ofblock, withIsHandledsupport to allow subscribers to handle custom document types and skip the standard case evaluation entirely.Event Signature:
Alternatives evaluated:
OnBeforeValidateIncludeHeaderandOnAfterValidateIncludeHeaderboth fire after thecaseblock has completed, so subscribers there cannot inject handling for unrecognized document types or correctFromSalesHeader. The available events are scoped to individual existing document type branches and cannot be reached for custom document types.