The CreatorCon Call for Content is officially open! Get started here.

Restrict one of the choices to be visible only for particular group

Hemamani Prabha
Tera Contributor

Hello all, 

In incident table, I have a requirement in which I need to show this option (Cyber Security) under category only to a particular group and admin. Others shouldn't see this option. How can I hide this ?

Someone please help with this.

 

HemamaniPrabha_0-1707480339007.png

 

Thanks,

Hema

 

5 REPLIES 5

Jyoti Tripathi
Giga Guru

You can use the client script and use remove option

 var currentUser = gs.getUser();
    var isAuthorized = false;

    if (currentUser.isMemberOf('group name') || currentUser.hasRole('admin')) {
        isAuthorized = true;
    }

    if (!isAuthorized) {
        g_form.removeOption('category_field', 'cyber_security_option');
    }



hello @Jyoti Tripathi 
this code didn't work as we cannot user isMemberOf function directly in client script.

shubhamdubey
Mega Sage

@Hemamani Prabha 

 

Write Display Br 

 

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

    // Add your code here

    g_scratchpad.grp = gs.getUser().isMemberOf('Team Development Code Reviewers');

})(current, previous);
 
Write onload client script :-
 
function onLoad() {

    //Type appropriate comment here, and begin script below

    var adminRole = g_user.hasRole('admin');

    alert(adminRole);

    if ((adminRole == true) && (g_scratchpad.grp == true)) {

        g_form.setValue('category', 'hardware');

    } else {

        return false;

    }

}

hi @shubhamdubey this code did not work