Securing Vendor bank details

Hi. I am currently a functional consultant taking my first steps into the technical side and have come across a rather urgent problem!

I have a 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. Then 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 when that didn’t work, 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 enter 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;
}

Ok so some modifications to my code.

I can now create a new record and enter the bank account number, once and once only! If I save it with a bank account number and then I go back in to edit it, I get a validation error.
This does what I wanted, because in order to make a payment to a different account, they need to set up a new bank account and then change the preferred bank account number on the vendor card - which I have the standard workflow on!

Now all I need to do is a page extension to 256 (payment journal) to make sure they can’t set up a new bank and then change it on the journal line. (make recipient bank code field not visible)

The only problem I can foresee is if they do not have a preferred bank account code on the vendor card it will slow them down while the go back and forth, because they can’t select it on the journal.

This is not a pretty solution - having a workflow event for the vendor bank details is needed!!!

Please feel free to use this.

pageextension 50100 “Vend Bank Card Ext” extends “Vendor Bank Account Card”
{
layout
{
modify(“Bank Account No.”)
{

trigger OnAfterValidate()

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

actions
{

}

trigger OnAfterGetCurrRecord()

begin
if Rec.“Code” = ‘’ then
IsNew := True
else
IsNew := false;
end;

var
IsNew: Boolean;

}

Just a further note - one thing I didn’t think of was what if the delete record 01 and then create new using the same code and different bank details?

trigger OnDeleteRecord(): Boolean
begin
Error(‘Delete option is not available’);
end;

Sorted!