- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 03:23 PM
Hello Community,
I would like users who are members of 'Generic Group' and are currently logged in to have access and to be able to see all the Assignment groups available on the Incident form. On the other hand, if a user who is currently logged in, is not a member of the 'Generic group', the group name 'Hidden Group' shall be hidden from that user.
My organization already has a script include in the assignment group field reference qualifier. I created a script include and tried to use it in addition to the my organization's script include and I also tried to use mine by itself but it still did not work.
Reference Qualifier:
javascript: myGroupFilter();
Script Include:
var myGroupFilter = Class.create();
myGroupFilter.prototype = {
initialize: function() {
if (gs.getUserID().isMemberOf('Generic Group'))
{ // User Can see all records
return;
}
else
{
return 'name!=Hidden Group'; // If user is not a member of the Generic Group Name then HIDE this Assignment group field.
}
},
type: 'myGroupFilter'
};
Below is what I had, I removed my organization's script include but it still did not work?
javascript: myOrganizationScriptInclude()+myGroupFilter();
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 11:55 AM
try
javascript: new MyOrgScriptInclude().getOrgQuery(current.u_org_field) + '^'+ new MyOrgScriptInclude().filter();
also change
var myGroupQuery = Class.create();
myGroupQuery.prototype = {
filter: function(){
if (!gs.getUser().isMemberOf('Generic Group Name')){
return 'name!=Hidden Group';
}else{
return '';
}
},
type: 'myGroupQuery'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 12:18 PM
Thank you, that helped.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 12:23 PM
Thanks, Looks like you marked your response as correct. Please make necessary update.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 06:47 PM
I'd advise doing this by role, not by group.
Give the group a role - something like 'assign_all_groups' and do your check based on role.
gs.hasRole('assign_all_groups');
Second, to that, I would give your hidden groups a type of 'hidden' and do your reference qualifier that way.
Why?
Because it is much more scalable.
You can assign the privileges out to other groups, change group names, or even assign to individuals (although not advised).
It is also easier to implement client-side controls with roles.
Think of a role as something that grants a capability, and Group membership grants capabilities to people.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 07:54 PM
Hi,
please try this simpler approach; no need to have script include
javascript: var query=''; if(!gs.getUser().isMemberOf('Generic Group')) query = 'name!=Hidden Group'; else query;
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader