isMemberOf function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2013 03:34 AM
Sorry if the answer is obvious...
I am trying to set up some logic based on a person being a member of a group. From the wiki I understand that ...gs.getUser().isMemberOf...can be used for this. This is part of my code:
if (gs.getUser().isMemberOf('Service Desk')) {
// hide it
g_form.setVisible('u_selection', false);
} else {
// unhide it
g_form.setVisible('u_selection', true);
}
However I keep getting this error:
Problem at line 2 character 18: Unexpected token: if (gs.getUser().isMemberOf('Service Desk')) {
I have been playing around with the code and I have read through the wiki and the community site, but I fail to see what is amiss.
Marc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2013 04:04 AM
Hi Marc,
I have tested your Script on my system. It's working
if(gs.getUser().isMemberOf('PC Management Team')) {
// hide it
gs.print("Test hide");
} else {
// unhide it
gs.print("Test unhide");
}
If you want to test on your system go to System Definition --> Scripts - Background try your script as
if(gs.getUser().isMemberOf('Service Desk')) {
// hide it
gs.print("Test hide");
} else {
// unhide it
gs.print("Test unhide");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2013 04:32 AM
?
System Definition --> Scripts - Background try your script as
I don't seem to have this module.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2013 04:38 AM
Hi,
Ask to ServiceNow about it they will give you more detail about this module.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2013 05:24 AM
It's probably there, but you have to elevate to the 'security_admin' role before it will become visible. You can do that by clicking the lock icon next to the impersonation icon. If it's still not there, you'll probably want to talk to SN support.