- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:27 AM
Hello I have a catalog item where I am trying to hide a multiple choice value from all users who access the form unless they are part of a specific group. However the script I am trying to run isnt working.
function onLoad() {
var targetGroup = '09745cc9c3302200e7c7d44d81d3ae6f';
// Check if the current user is a member of the target group
if (!g_user.isMemberOf(targetGroup)) {
// Remove "op_3" option if the user is not a member of the group
g_form.removeOption('choice', 'op_3');
}
}
Does anyone see an issue with this approach? It seems like it should be a pretty simple script.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:56 AM
Hello @dagarson ,
I doubt if isMemberOf is even a method of g_form object. isMemberOf is a method available in GlideUser object which works on the server side.
For your case I think you should try and create a client callable script include and do your validation there.
Please do leave a thumbs up if my response helped you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:36 AM - edited ‎08-19-2024 06:37 AM
Use the name of the group as your argument, not the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:44 AM
Thank you for responding. I gave that a try and it didnt seem to make a difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:37 AM
Hi @dagarson ,
Step 1: Create a display Business rule with script as. Place the below script between function templates in script body.
g_scratchpad.grp = gs.getUser().isMemberOf('PASS GROUP NAME HERE');
Now update the client script as
function onLoad() {
if (!g_scratchpad.grp){
g_form.removeOption('choice', 'op_3');
}
}
Mark helpful if it really help you.
Thanks
Bk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:55 AM
Thanks for responding. Does the Business Rule need to run on a specific table? I tried it with none and with the ritm table and it didnt work on either.