How to make a particular choice field only available for particular user group

spimple
Tera Contributor

I have a requirement in which it has been mentioned that I need to make a choice value named ACB to make available only for User group named Cloud. How to achieve this ? Is it possible using ACL or CLient script ot BR ??

1 REPLY 1

Clara Lemos
Mega Sage
Mega Sage

Hi @spimple ,

 

You can create a Display Business rule to check if the user is a member of the Cloud group, and in a Client Script you can remove the option ACB depending if the user is a member of the group or not. 

 

To do that, first you'll need to create a Business Rule on display on the proper table.

Screenshot 2024-01-29 at 12.58.53.png

 

In the Advanced tab you'll need a code like this:

 

(function executeRule(current, previous /*null when async*/) {

g_scratchpad.CurrentMembership = gs.getUser().isMemberOf("Cloud");

})(current, previous);

 

Now for the Client Script, it should be onLoad 

And you for your script you could use something like this:

function onLoad() {
    if (g_scratchpad.CurrentMembership == false) {
        g_form.removeOption('category', 'ACB'); // here you should add the name of your field instead of category
    }
}

 

If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know

Cheers