Show assignment groups for particular HR Service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 11:36 AM - edited ‎12-20-2023 11:43 AM
Hi
I'm looking for an option to combine both reference qualifiers into one OR add logic from the first reference qualifier to the script include.
For HR Case and a specific HR Service, I want to choose only assignment groups where the user is a member. When the particular HR Service is used on a case, the user should only be able to choose groups of which they are a member (here I don't what to use escalation script). In other cases, the escalation script from the script include should run.
I tried to return the caseSysid when hr_service is <sys_id of a particular HR service>, but it didn't work.
ref qualifier 1: sys_idINjavascript:gs.getUser().getMyGroups();
ref qualifier on HR Case: javascript: new HRCaseUtils().escalations(current.sys_id);
script include:
escalations: function(caseSysid) {
var query = 'sys_idIN';
var hrCase = new GlideRecord('sn_hr_core_case');
hrCase.get(caseSysid);
var groups = new GlideRecord('sn_hr_core_escalations');
groups.addQuery('u_matcher', hrCase.assignment_group);
groups.query();
while(groups.next()) {
query += groups.u_setter + ',';
}
return query;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:43 PM
Yes I think so, but not sure 💯 whether this will also work for you or not but still you can give a try since I have modified it as per your requirement and also have added some logs so that we could get some idea.
var HRCaseUtils = Class.create();
HRCaseUtils.prototype = {
getAssignmentGroups: function(caseSysid) {
var hrCase = new GlideRecord('sn_hr_core_case');
if (hrCase.get(caseSysid)) {
var userGroups = gs.getUser().getMyGroups();
// Log userGroups for debugging
gs.log('User Groups: ' + userGroups.join(','));
// Check if the HR Service matches the specific HR Service you are targeting
if (hrCase.hr_service == '<sys_id_of_your_specific_HR_Service>') {
var result = 'sys_idIN' + userGroups;
gs.log('Result for Specific HR Service: ' + result);
return result;
} else {
var result = this.escalations(caseSysid);
gs.log('Result for Escalations: ' + result);
return result;
}
}
gs.log('No HR Case found for sys_id: ' + caseSysid);
return '';
},
escalations: function(caseSysid) {
var query = [];
var hrCase = new GlideRecord('sn_hr_core_case');
if (hrCase.get(caseSysid)) {
var groups = new GlideRecord('sn_hr_core_escalations');
groups.addQuery('u_matcher', hrCase.assignment_group);
groups.query();
while(groups.next()) {
query.push(groups.u_setter);
}
// Log query for debugging
gs.log('Query for Escalations: ' + query.join(','));
var result = 'sys_idIN' + query;
gs.log('Result for Escalations: ' + result);
return result;
}
gs.log('No HR Case found for sys_id: ' + caseSysid);
return '';
},
type: 'HRCaseUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:42 PM
@Aniket Chavan
one more question. I forgot to use new created method in ref qualifier. Is it possible to use two functions in ref qualifier?
javascript: new HRCaseUtils().escalations(current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:52 PM - edited ‎12-20-2023 12:53 PM
Hello @miro2 ,
@I think yess but for that you need to modify the script include, you can merge you both functions in the script include itself and create 3rd function and then call that 3rd function inside of reference qualifier.
You can refer to the below community article on which they have did the exact same thing.
how to add two functions from script include in a reference qualifier