- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 08:46 AM
Hello Community,
We have a requirement to filter assignment groups on HR cases bases on coe security policies.
I have updated the reference qual (dictionary override on sn_hr_core_case table) and created a client callible script include however its not working.
Can someone please advise?
Reference qual:
javascript : new sn_hr_core.HRAssignmentFilterUtil().getHRService(current.hr_service);
script include:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 08:55 AM - edited 02-05-2025 09:04 AM
Few pointers
1) don't use gs.log(), use gs.info()
2) you are using wrong syntax to push value into array
3) you are comparing wrong value so I updated this line -> security_policy is reference so compare with sys_id
4) ensure you are giving correct query -> is it AND or OR -> give it correctly here
update as this
var HRAssignmentFilterUtil = Class.create();
HRAssignmentFilterUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getHRService: function(a) {
gs.info("Script Include called ");
var hrservice = a;
var groups = [];
var gr1 = new GlideRecord('sn_hr_core_coe_security_policy');
gr1.addQuery('services', "CONTAINS", hrservice);
// ensure you are giving correct query
gr1.addOrCondition('type', 'write');
gr1.query();
if (gr1.next()) {
var gr2 = new GlideRecord('sn_hr_core_m2m_security_policy_group');
gr2.addQuery('security_policy', gr1.sys_id);
gr2.query();
while (gr2.next()) {
groups.push(gr2.group.sys_id.toString());
}
}
return 'sys_idIN' + groups.toString();
},
type: 'HRAssignmentFilterUtil'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 08:55 AM - edited 02-05-2025 09:04 AM
Few pointers
1) don't use gs.log(), use gs.info()
2) you are using wrong syntax to push value into array
3) you are comparing wrong value so I updated this line -> security_policy is reference so compare with sys_id
4) ensure you are giving correct query -> is it AND or OR -> give it correctly here
update as this
var HRAssignmentFilterUtil = Class.create();
HRAssignmentFilterUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getHRService: function(a) {
gs.info("Script Include called ");
var hrservice = a;
var groups = [];
var gr1 = new GlideRecord('sn_hr_core_coe_security_policy');
gr1.addQuery('services', "CONTAINS", hrservice);
// ensure you are giving correct query
gr1.addOrCondition('type', 'write');
gr1.query();
if (gr1.next()) {
var gr2 = new GlideRecord('sn_hr_core_m2m_security_policy_group');
gr2.addQuery('security_policy', gr1.sys_id);
gr2.query();
while (gr2.next()) {
groups.push(gr2.group.sys_id.toString());
}
}
return 'sys_idIN' + groups.toString();
},
type: 'HRAssignmentFilterUtil'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 09:09 AM
Awesome, thanks Ankur. Its working now.
One issue. There are few HR cases where HR service is empty. and there could be few scenarios where coe security rule might not be present. What is the recommended approach for such cases?
Do we show all HR groups as we dont agents not able to assign cases to any assignment groups..and cases are lying in limbo..
Please advise..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 07:06 PM
Glad to know that my script worked.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 07:06 PM
Best to discuss with customer. In this case you can show all groups.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader