How to find Member in a Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2013 12:09 AM
Hi,
I am creating a In Bound action for Resolving an Incident. For which i need to find out whether the person is part of the group assigned in the Incident.
This user value should be read from an email and search in the current group assigned in the Incident.
Can any one help on getting the script. Below is the script I am usng to validate user which doesnt seem to be working.
var memb = email.from.sys_id;
gs.log(memb);
if(memb.isMemberOf(current.assignment_group) == true)
Thanks,
Vamsee.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2013 07:29 AM
needs to be a user object to use the method
memb
.
isMemberOf
In versions of SN prior to calgary, sn searches the user table for the user with a sys_user.user_name matching before the @ for a match. So if the email isn't representative of the user's user_name it wont find him. In calgary it does searches for a user who has that email address. http://wiki.servicenow.com/index.php?title=Inbound_Email_Actions#Matching_Email_Addresses_to_Existing_Users
http://wiki.servicenow.com/index.php?title=Getting_a_User_Object
Try this assuming your not on Calgary;
var sys_user = new GlideRecord('sys_user');
var found = sys_user.get('email', email.from);
if (found) {
var user = gs.getUser();
user = user.getUserByID(sys_user.sys_id);
gs.log(user);
if (user.isMemberOf(current.assignment_group) == true) {
//do something
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2013 05:15 AM
Hi,
I have added few statements to the above script, pleae see below, which doesn't seen to be working.
Can you please let me know if I am missing anything.
if (current.getTableName() == "incident" && email.subject.indexOf("Resolved") >= 0)
{ var sysuser = new GlideRecord('sys_user');
var found = sysuser.get('email', email.from);
if (found) {
gs.log("Updating Incident");
var user = gs.getUserID();
//user = user.getUserByID(sys_user.sys_id);
gs.log(user);
if (user.isMemberOf(current.assignment_group) == true) {
//current.assigned_to = sysuser.get('email', email.from);//email.from_sys_id;
current.assigned_to = email.from.sys_id;
current.close_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.close_code = "Analyst Resolution";
}
}
}
else
{
gs.log("Resolution for task is rejected");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2013 08:56 AM
Not sure if this is the reason, but on line 3 you have
"var found = sysuser.get('email', email.from);"
then inside your if statement you reference the same user with:
"current.assigned_to = email.from.sys_id;"
One of these two probably works in getting the user's sys_id, but I doubt both do.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2013 09:13 AM
I believe you probably want to replace this;
current.assigned_to = email.from.sys_id;
With this;
current.assigned_to = sysuser.sys_id;