- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:22 AM
Hello, I need to filter the Assigned To values based on value of another field. If the condition is not met, I need to display the full list of group members for that specific assignment group. Below is my attempt thus far... any insight or ideas?
Condition: If "u_hr_confidential" = Yes, only display the users with role "sn_hr_core.u_hr_confidential" from assignment_group in assigned_to.
Else, display all users in assignment group.
Reference Qualifier on Assigned To
javascript: new sn_hr_core.HrCaseAjaxUtils().getConfidential(current.u_hr_confidential);
Script Include
var HrCaseAjaxUtils = Class.create();
HrCaseAjaxUtils.prototype = {
initialize: function() {
},
getConfidential: function(field) {
var confidential = current.u_hr_confidential;
if (field == 'Yes') {
gs.info("HRSD1: " + role);
gs.info("HRSD2: " + confidential);
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('user.roles=sn_hr_core.u_hr_confidential');
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.sys_id.toString());
}
return 'sys_idIN' + arr.toString();
}
},
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 12:51 PM
Using a combination of all recommendations, I have resolved the issue while keeping the script include Client Callable.
var HrCaseAjaxUtils = Class.create();
HrCaseAjaxUtils.prototype = {
initialize: function() {},
getConfidential: function(u_hr_confidential) {
gs.info("HRSD1: " + u_hr_confidential);
if (u_hr_confidential == 'Yes') {
gs.info("HRSD2: " + u_hr_confidential);
var arr = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',current.assignment_group);
gr.addEncodedQuery('user.roles=sn_hr_core.u_hr_confidential');
gr.query();
while (gr.next()) {
arr.push(gr.user.toString());
}
return 'sys_idIN' + arr;
}
},
type: 'HrCaseAjaxUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:37 AM
Hello @heathers_ ,
Please correct the below line.
javascript: new sn_hr_core.HrCaseAjaxUtils().getConfidential(current.variables.u_hr_confidential);
Same type of requirement please follow the Ref URL: https://www.servicenow.com/community/developer-forum/advanced-reference-qualifier-in-servicenow-base...
Please Mark My Answer as Helpful and Accept as Solution, if you find this article helpful or resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:41 AM
@Appanna M Thank you for your response. These are not variables. I am creating this directly on the sn_hr_core_case table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:48 AM
You script include doesnt need to be client
There are several correction you need to make
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',current.assignment_group); // You should query the assignment group as well
gr.addEncodedQuery('user.roles=sn_hr_core.u_hr_confidential');
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.getValue('user')); // You should pass the user sysid here
}
return 'sys_idIN' + arr.toString();
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 12:43 PM
I don't need to make this client callable?
Adjusting based on your recommendations and assigned_to is displaying the complete list of group members. Still not seeing the few members with the queried role.