Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Table 36 "Sales Header" - Add OnValidateBillToCustomerNoOnAfterCheckBilltoCustomerNoChanged IsHandled pattern #28186

Open
thomari opened this issue Feb 20, 2025 · 0 comments

Comments

@thomari
Copy link

thomari commented Feb 20, 2025

Describe the request

Please add the IsHandled --> Exit pattern to the OnValidateBillToCustomerNoOnAfterCheckBilltoCustomerNoChanged Publisher in the "Bill-to Customer No." OnValidate trigger.

Previous Code

field(4; "Bill-to Customer No."; Code[20])
{
    Caption = 'Bill-to Customer No.';
    NotBlank = true;
    TableRelation = Customer;

    trigger OnValidate()
    var
        IsHandled: Boolean;
    begin
        TestStatusOpen();
        BilltoCustomerNoChanged := xRec."Bill-to Customer No." <> "Bill-to Customer No.";

        IsHandled := false;
        OnValidateBillToCustomerNoOnAfterCheckBilltoCustomerNoChanged(Rec, xRec, CurrFieldNo, IsHandled);

        if BilltoCustomerNoChanged and not IsHandled then
            if xRec."Bill-to Customer No." = '' then
                InitRecord()
            else
                if ConfirmBillToCustomerChange() then begin
                    OnValidateBillToCustomerNoOnAfterConfirmed(Rec);

                    SalesLine.SetRange("Document Type", "Document Type");
                    SalesLine.SetRange("Document No.", "No.");

                    CheckShipmentInfo(SalesLine, true);
                    CheckPrepmtInfo(SalesLine);
                    CheckReturnInfo(SalesLine, true);

                    SalesLine.Reset();
                end else
                    "Bill-to Customer No." := xRec."Bill-to Customer No.";

        ... // other code
    end;
}

New Code

field(4; "Bill-to Customer No."; Code[20])
{
    Caption = 'Bill-to Customer No.';
    NotBlank = true;
    TableRelation = Customer;

    trigger OnValidate()
    var
        IsHandled: Boolean;
    begin
        TestStatusOpen();
        BilltoCustomerNoChanged := xRec."Bill-to Customer No." <> "Bill-to Customer No.";

        IsHandled := false;
        OnValidateBillToCustomerNoOnAfterCheckBilltoCustomerNoChanged(Rec, xRec, CurrFieldNo, IsHandled);
        if IsHandled then
            exit;

        if BilltoCustomerNoChanged and not IsHandled then
            if xRec."Bill-to Customer No." = '' then
                InitRecord()
            else
                if ConfirmBillToCustomerChange() then begin
                    OnValidateBillToCustomerNoOnAfterConfirmed(Rec);

                    SalesLine.SetRange("Document Type", "Document Type");
                    SalesLine.SetRange("Document No.", "No.");

                    CheckShipmentInfo(SalesLine, true);
                    CheckPrepmtInfo(SalesLine);
                    CheckReturnInfo(SalesLine, true);

                    SalesLine.Reset();
                end else
                    "Bill-to Customer No." := xRec."Bill-to Customer No.";

        ... // other code
    end;
}

Additional context

We need to run our own code in certain instances and be able to skip the standard validate trigger. Same implementation as you already have in the "Sell-to Customer No." OnValidate trigger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant