Restrict one of the choices to be visible only for particular group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 04:08 AM
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.
Thanks,
Hema
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 04:18 AM
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');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:43 AM
hello @Jyoti Tripathi
this code didn't work as we cannot user isMemberOf function directly in client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 04:42 AM - edited 02-09-2024 04:44 AM
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);
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:44 AM
hi @shubhamdubey this code did not work