how to Check user is belong to this group or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 11:19 PM
When i click on "Assign to me" UI ACTION -button user name is filled in "Assign to" , but user is not belongs to "project Mgnt" group then display message- ''user not in this group''.
var aa=g_user.getUserID();
g_form.setValue('u_assign_to_me',aa);
now i want , 1. if user belong to that group display username in "Assign To" filed
2. if user is not belongs to that assignment group should display message, and assignment group should become blank but display username in "Assign To" filed and based on username ''Assignment Group'' display user related groups in ''Assignment Group'' field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 12:23 AM
I gave the script as per details you mentioned in earlier notes
In that case, you have to restrict the group membership based on assigned to users via reference qualifier. Please refer below link for more info.
4.3.2.2 section here
http://wiki.servicenow.com/index.php?title=Reference_Qualifiers#gsc.tab=0
P.S: In that case your updated script is
current.assigned_to = gs.getUserID();
if(gs.getUser().isMemberOf(current.assignment_group)){
}
else {
current.assignment_group = "";
}
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 12:48 AM
code:
current.u_assign_to_me = gs.getUserID();
if(gs.getUser().isMemberOf('current.assignment_group'))
{
//do nothing
}
else
{
current.assignment_group = '';
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', gs.getUserID());
gr.query();
if(gr.next())
{
current.assignment_group = gr.group;
}
current.update();
}
i have removed all restrictions . there no problem with your code it's working Good
but problem is ,can we populate Groups in Assignment Group based on user name in which group he is being as a member .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 07:35 AM
You have mentioned "but problem is ,can we populate Groups in Assignment Group based on user name in which group he is being as a member ."
PS: Did you got a chance to go through reference qualifier link I have shared?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 02:54 PM