web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Making Vendor bank details so they cannot be edited

(0) ShareShare
ReportReport
Posted on by 35

Hi. I have an urgent requirement to make vendor bank details non - editable once in. I have a workflow on the vendor card for changes so if someone changes the preferred bank code it will need to be authorised.

The theory is to make vendor bank details error if the account number is changed but if it is a new record allow them to be entered. Then on the payment journal make it so that changes to the preferred bank account can not be edited and must come from the vendor card. (I was thinking make this field not visible on the journal - if they can't get to it they can't edit it.)

I have tried by creating a boolean for a new record. The using the OnValidate check if it is a new record - if it is exit, if not error. 

I have tried with a table extension(first with no success) using the OnBeforeInsert trigger to set NewRec true and then on a page extension using the OnOpenPage to do the same.

I have put the code below: The result is I can't edit the Bank Account number on an existing record - when you navigate away from the page it gives the error message which is what I wanted, but I can't edit the bank account number on a new record either! Can someone point me in the right direction? It appears to me that my variable NewRec never gets initialised. Please help!

pageextension 50100 "Vend Bank Card Ext" extends "Vendor Bank Account Card"
{
    layout
    {
        modify("Bank Account No.")
        {
            trigger OnBeforeValidate()

            begin
                if NewRec = true then
                    exit
                else
                    Error('Cannot change Bank details - Create a new record');
            end;

            trigger OnAfterValidate()

            begin
                if NewRec = true then
                    exit
                else
                    Error('Cannot change Bank details - Create a new record');
            end;
        }
    }

    actions
    {

    }
    trigger OnOpenPage()

    begin
        if rec.Code <> '' then
            NewRec := true;
    end;

    var
        NewRec: Boolean;
}
I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,237 Super User 2025 Season 2 on at
    RE: Making Vendor bank details so they cannot be edited

    You could add something like this because for new records Bank Account No. is blank and if they try to modify after it has a value then it will error out.

    trigger OnAfterValidate()

               begin

                   if (Rec."Bank Account No." <> xRec."Bank Account No.") and (xRec."Bank Account No." <> '') then

                       Error('Cannot Edit')

               end;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,056

#2
YUN ZHU Profile Picture

YUN ZHU 1,680 Super User 2025 Season 2

#3
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 1,679

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans