select a group in assignment group field so in assigned to only particular grpmemebr see not all us

ishwarsingh
Tera Contributor

 

var grUser = new GlideRecord("sys_user_grmember");
grUser .addQuery("group", current.u_assignment_group);
grUser .addQuery('user', '!=', current.u_assigned_to);
grUser .query();
var querStr = '';
while (gr.next()) {
if (querStr == '') {
querStr = 'sys_idIN' + grUser .getValue('user');
} else {
querStr += ',' + grUser .getValue('user');
}
}
return querStr;
},

 

 

1 ACCEPTED SOLUTION

Rafael Batistot
Tera Sage

Hi @ishwarsingh 

in your code you've started with  "var grUser = new GlideRecord" and in your "while" loop you've inserted "while (gr.next()) {". This is not correct

May you try 

var grUser = new GlideRecord("sys_user_grmember");
grUser.addQuery("group", current.u_assignment_group);
grUser.addQuery("user", "!=", current.u_assigned_to);
grUser.query();

var querStr = '';
while (grUser.next()) {
    if (querStr == '') {
        querStr = 'sys_idIN' + grUser.getValue('user');
    } else {
        querStr += ',' + grUser.getValue('user');
    }
}

return querStr;




View solution in original post

6 REPLIES 6

Hi @ishwarsingh ,

 

For this you can refer the solution provided in this post by me Make Assignment group dynamic - ServiceNow Community.

 

This is just opposite of what you did for assignee based on assignment group. Actually you don't need script to show only assignee which are part of assignment group, because this is alaredy OOTB feature, you can confirm by checking the dictionary configuration of assigned_to in depedent field it should have 'assignment_group'. As screenshot provided by @Brian Lancaster .

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Hey @ishwarsingh ,

 

Did you get a chance to review my reply for your latest question here.


If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. It will help future readers as well having similar kind of questions and close the thread.

Thanks,
Bhimashankar H