Visibility of BankAccountNumber only for the selected record in form

Hi all,

I have a requirement in which Bank Account numbers should be masked to all users in form\BankAccountTableListPage and can be viewed only by the users who are added to a specific role by a button click.

  • When the user opens the forms initially all the values in Bank AccountNum should be masked (*********)

  • Button is visible to only users who are added to a specific role. Suppose User A have access to view the bank account number then user clicks on the button , with the button click he should be able to view the bank account number for the selected record.

Implementation: I have created a display method in table\BankAccountTable to get the masked BankAccountNumber .Added a new control on the form and specified the data method.

When I open the form all the values for the BankAccountNumber are masked .

The issue is when I try to select a record and click the button I am able to view bank accountnumbers for all the records. [ My requirement is only for the selected record I should able to view BankAccountNum and for the rest of the records it should be masked]

Any help is appreciated !

What button click is doing? If possible, please show us the code.

Hi Kranthi ,
Sorry to miss that . In the form there is already an existing control which displays bank account num

  • Added new control (maskbankAccnum) and specified data method
    Void Clicked ()
    {
    If (bankAccnum.visible())
    {
    Bankaccnum.visible(false);
    Maskbankaccnum.visible(true);
    }
    Else
    {
    Bankaccnum.visible(true);
    Maskbankaccnum.visible(false);
    }
    }
    Button click should be vice versa in displaying the mask and unmask value .
    I have tried with control visibility which always gives me data irrespective of the record selected.
    Can you please provide any other approach to achieve this ?

You may not be able to handle this by setting visibility, as this is not row specific.
One thing you can try is to use a single control with a display method that shows bankAccountNum or Mask based on the condition.
To set condition, one way is to use cache (SysGlobalObjectCache) and insert into cache when the button is clicked and use the same cache in the display method whether to show the account number or mask.

Merely to show a different coding style, look at how your code could be simplified (and notice how proper and consistent casing makes names easier to read):

void clicked()
{
    boolean wasVisible = BankAccNum.visible();
    
    BankAccNum.visible(   !wasVisible);
    MaskBankAccNum.visible(wasVisible);
}

Thank you Kranthi.I will try that and let you know the outcome

Thank you Martin ! I will follow that .

Hello Kranthi ,
I have tried using sysGlobalObjectCache and used the condition in display method.
Since we are using the display method all the records are getting affected irrespective of the selected record .
Any suggestions please ?

Can you please show the code?

Hello Kranthi,
I have written the logic as below:

  • The naming convention i have used is just for testing purpose.

In Class declaration declared 2 variables
SysGlobalObjectCache SysGlobalObjectCache ;
str isClicked;

// Created display method in form datasource
display BankAccount
maskBankAccTest(BankAccountTable _bankAccountTable)
{
container c;
BankAccount account;

c = SysGlobalObjectCache.find(“Status”,[isClicked]);

if (conFind(c,“init”)) // When form opens initially by default all the fields should be masked
{
account = BankAccountMasking::maskBankAcc(_bankAccountTable.AccountNum);// gets masked value

}
else if(conFind(c,“Clicked”)) // when button is clicked , only for the selected record the bank account num should be
visible.
{
account = _bankAccountTable.AccountNum;
}
return account;

}

// In button clicked method inserting the value “clicked”

SysGlobalObjectCache.insert(“Status”,[isClicked],[“Clicked”]);

// In form init method inserting the value “init”

SysGlobalObjectCache.insert(“Status”,[isClicked],[“init”]);

Can you please correct me ?

You are not caching the record (by selecting which you have clicked the button). That is whole purpose of using it.
Instead having a field and updating it every time and showing the bankAccountNum value based on it, we are using caching. You can set the Key a RecId and a Boolean as value, that indicates whether to show the mask or bank account number.

Thank you Kranthi!
I will modify the code.