Skip to content

[W1][Report][292][Copy Sales Document] Add integration event OnBeforeValidateDocNo in ValidateDocNo() procedure to handle custom source document type in the case block. #30121

@mavohra

Description

@mavohra

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions