- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 01:10 PM
Hello
I have a requirement for a notification when a Request is submitted via Self-Service.
I need the advanced condition to lookup the User's group membership and if is a member of a certain group, do not trigger the email.
I saw this script on another user's question, but I cannot seem to get it to work. Any suggestions?
So logically - the script should look up the user's group membership and if XXX group is found, then return false and not generate email.
Thanks in advance!
if (!isGroupMember(current.opened_by, 'group here') ) {
answer = true;
} else {
answer = false;
}
var grpMbr = new GlideRecord('sys_user_grmember');
grpMbr.addQuery('user', userID);
grpMbr.addQuery('group', groupID);
grpMbr.query();
if (grpMBR.next()) {
return true;
} else {
return false;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 12:01 PM
Hi Josh,
You are getting that error because using a "return" expects you to be using it within a function. Instead try setting the variable "answer = true;" (or false).
i.e.,
var grpMbr = gs.getUser();
if(grpMbr.isMemberOf('Service Desk')){
answer = false;
}
else{
answer = true;
}
However as mentioned earlier, you should be able to skip the "if" statement since isMemberOf() returns a true/false on it's own. You could just use:
answer = !gs.getUser().isMemberOf('Service Desk');
Just for efficiency's sake.
Thanks,
-Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 01:58 PM
Seems like you could just use isMemberOf to check the group:
var grpMbr = gs.getUser();
if (grpMbr.isMemberOf('Service Desk')){
return false;
else {
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2016 07:15 AM
Hello Michael
Stupid question - do you know why I'm getting a response of 'Invalid Return" for the return false?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2016 07:52 AM
Hi Josh,
You just need to put below line in the advanced condition box. Advanced condition expects a boolean value as a result so the error.
gs.getUser().isMemberOf('Service Desk')
thanks
Srini
Mark this response as correct/helpful if does so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 09:20 AM
Hello Michael
I appreciate your response...but as is, the return is saying invalid no matter what I add to the script.
Can you suggest what I'm doing wrong?
Thanks