Restrict access to choose a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 05:07 AM
Hi,
I need some help with a part of code.
I want to restrict access to assign tickets to one of a group, it should available only if user is Member of specific group.
So I have something like that:
(function executeRule(current, previous /*null when async*/) {
if (gs.getUser().isMemberOf('bd72a95e1b7c355062cfca62604bcb9c')) {
current.addQuery('sys_id', '3d72a95e1b7c355062cfca62604bcb90');
}
})(current, previous);
But unfortunately it doesn't work properly cause here if user is member of group "ABC" can see only group "XYZ",
nad That's what I want to make, group "XYZ" should be able to choose/visible only by users which are member of group "ABC"
- Labels:
-
Incident Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 05:12 AM
Hi @DIVI1
Change your script to
if (gs.getUser().isMemberOf('bd72a95e1b7c355062cfca62604bcb9c')) { //sys_id of ABC
current.addQuery('assignmnet_group', '3d72a95e1b7c355062cfca62604bcb90'); //Sys_id of XYZ group
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 05:23 AM
Hi,
Thanks Now users of group ABC can see all groups and that's fine, but users which are not member of group ABC still can choose group "XYZ" from assignment_group field. How to restrict that ? "else" something I think?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 05:26 AM
Try this:
if (gs.getUser().isMemberOf('bd72a95e1b7c355062cfca62604bcb9c')) { //sys_id of ABC
current.addQuery('assignmnet_group', '3d72a95e1b7c355062cfca62604bcb90'); //Sys_id of XYZ group
}
else{
current.addQuery('assignmnet_group', '!=', '3d72a95e1b7c355062cfca62604bcb90'); //Sys_id of XYZ group
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 05:35 AM
Still the same, maybe remove option or something ?