Skip to content

[Event Request] Table 31257 "Payment Order Line CZB"."No.".OnValidate #29852

@fridrichovsky

Description

@fridrichovsky

Why do you need this change?

Actual validation clear "Cust./Vendor Bank Account Code" when Preferred Bank Account Code is not set on Customer or Vendor. We need keep previous set value. It is reason why we ask for event that allows set that only filled Preferred Bank Account Code will be set.

Describe the request

field(4; "No."; Code[20])
    {
        Caption = 'No.';
        TableRelation = if (Type = const(Customer)) Customer."No." else
        if (Type = const(Vendor)) Vendor."No." else
        if (Type = const("Bank Account")) "Bank Account"."No." else
        if (Type = const(Employee)) Employee."No.";
        DataClassification = CustomerContent;

        trigger OnValidate()
        var
            BankAccount: Record "Bank Account";
            Customer: Record Customer;
            Vendor: Record Vendor;
            Employee: Record Employee;
            // ------------------------------------- OnValidateNoOnAfterInit:BEGIN
            SetOnlyFilledPrefBankAccount: Boolean;
            // ------------------------------------- OnValidateNoOnAfterInit:END
        begin
            TestStatusOpen();
            if "No." <> xRec."No." then begin
                if CurrFieldNo = FieldNo("No.") then begin
                    PaymentOrderLineCZB := Rec;
                    Init();
                    Validate("Payment Order No.");
                    Type := PaymentOrderLineCZB.Type;
                    "No." := PaymentOrderLineCZB."No.";
                end;
                // ------------------------------------- OnValidateNoOnAfterInit:BEGIN
                OnValidateNoOnAfterInit(Rec, SetOnlyFilledPrefBankAccount);
                // ------------------------------------- OnValidateNoOnAfterInit:END
                case Type of
                    Type::Customer:
                        begin
                            if not Customer.Get("No.") then
                                Customer.Init();
                            Customer.Testfield(Blocked, Customer.Blocked::" ");
                            Customer.Testfield("Privacy Blocked", false);
                            Name := Customer.Name;
                            "Payment Method Code" := Customer."Payment Method Code";
                            // ------------------------------------- OnValidateNoOnAfterInit:BEGIN
                            if (not SetOnlyFilledPrefBankAccount) or (Customer."Preferred Bank Account Code" <> '') then
                            // ------------------------------------- OnValidateNoOnAfterInit:END
                                Validate("Cust./Vendor Bank Account Code", Customer."Preferred Bank Account Code");
                        end;
                    Type::Vendor:
                        begin
                            if not Vendor.Get("No.") then
                                Vendor.Init();
                            Vendor.Testfield(Blocked, Vendor.Blocked::" ");
                            Vendor.Testfield("Privacy Blocked", false);
                            Name := Vendor.Name;
                            "Payment Method Code" := Vendor."Payment Method Code";
                            // ------------------------------------- OnValidateNoOnAfterInit:BEGIN
                            if (not SetOnlyFilledPrefBankAccount) or (Vendor."Preferred Bank Account Code" <> '') then
                            // ------------------------------------- OnValidateNoOnAfterInit:END
                                Validate("Cust./Vendor Bank Account Code", Vendor."Preferred Bank Account Code");
                        end;
                    Type::"Bank Account":
                        begin
                            if not BankAccount.Get("No.") then
                                BankAccount.Init();
                            BankAccount.Testfield(Blocked, false);
                            "Account No." := BankAccount."Bank Account No.";
                            "Specific Symbol" := BankAccount."Default Specific Symbol CZB";
                            "Transit No." := BankAccount."Transit No.";
                            IBAN := BankAccount.IBAN;
                            "SWIFT Code" := BankAccount."SWIFT Code";
                            Name := BankAccount.Name;
                        end;
                    Type::Employee:
                        begin
                            if not Employee.Get("No.") then
                                Employee.Init();
                            Employee.Testfield("Privacy Blocked", false);
                            "Account No." := Employee."Bank Account No.";
                            IBAN := Employee.IBAN;
                            "SWIFT Code" := Employee."SWIFT Code";
                            Name := Employee.FullName();
                        end;
                end;
            end;
        end;
    }
// ------------------------------------- OnValidateNoOnAfterInit:BEGIN
[IntegrationEvent(false, false)]
local procedure OnValidateNoOnAfterInit(var PaymentOrderLineCZB: Record "Payment Order Line CZB"; var SetOnlyFilledPrefBankAccount: Boolean)
begin
end;
// ------------------------------------- OnValidateNoOnAfterInit:END

Internal work item: AB#626283

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an event

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions