isMemberOf function

Marc_Heyvaert
Kilo Contributor

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

8 REPLIES 8

Sanjeev Kumar1
Kilo Sage

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");
}



Marc_Heyvaert
Kilo Contributor

?
System Definition --> Scripts - Background try your script as
I don't seem to have this module.


Hi,

Ask to ServiceNow about it they will give you more detail about this module.


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.