- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 01:41 PM
When "Assigned to" is filled out on any forms (SCTask, Incident, etc) I need to be able to filter the "Assignment group" so that it only shows the groups the Assigned to is a member of.
Is there a way to do this? Client Script? Advanced Filter?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 02:32 PM
Hi @SSuddarth ,
OOTB when you select assignment group, In assigned to you will get the member of the assignment group selected if you want it in reverse then you can try the below possible ways,
another way is to create script include and call it from reference qualifier,
Tried forAssignment group field in Task table ,
Reference qualifier,
javascript: new getAssignedToGroup().getGroups(current.assigned_to);
Script Include:
var getAssignedToGroup = Class.create();
getAssignedToGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function(sysId) {
gs.info('sysid ' + sysId);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', sysId);
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.getValue('group'));
}
gs.info('array ' + arr);
return 'sys_idIN'+ arr.toString();
},
type: 'getAssignedToGroup'
});
Result:
Note: As you are doing this on Task table variable Assignment group This will be Global change .
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 11:58 AM
Hi @SSuddarth ,
I have updated the script include please give it a try,
var getAssignedToGroup = Class.create();
getAssignedToGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function(sysId) {
gs.info('sysid ' + sysId);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', sysId);
//gr.addExtraField('group.type','itil');
gr.query();
var arr = [];
while (gr.next()) {
if (gr.group.type.indexOf(gs.getProperty('SysId.itil.type')) > -1 ) //created a system property SysId.itil.typeand stored type itil backend sys id
{
gs.info('type', gr.group.type);
gs.info('inside if');
arr.push(gr.getValue('group'));
}
}
gs.info('arra' + arr.toString());
if (arr.length == 0) {
gs.info('inside false side');
return 'sys_idIN' + '';
} else {
return 'sys_idIN' + arr.toString();
}
},
type: 'getAssignedToGroup'
});
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 02:32 PM
Hi @SSuddarth ,
OOTB when you select assignment group, In assigned to you will get the member of the assignment group selected if you want it in reverse then you can try the below possible ways,
another way is to create script include and call it from reference qualifier,
Tried forAssignment group field in Task table ,
Reference qualifier,
javascript: new getAssignedToGroup().getGroups(current.assigned_to);
Script Include:
var getAssignedToGroup = Class.create();
getAssignedToGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function(sysId) {
gs.info('sysid ' + sysId);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', sysId);
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.getValue('group'));
}
gs.info('array ' + arr);
return 'sys_idIN'+ arr.toString();
},
type: 'getAssignedToGroup'
});
Result:
Note: As you are doing this on Task table variable Assignment group This will be Global change .
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 08:12 AM
The script include worked perfectly! Thank you!
What if I want to include a second condition such as "Type is itil"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 11:58 AM
Hi @SSuddarth ,
I have updated the script include please give it a try,
var getAssignedToGroup = Class.create();
getAssignedToGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function(sysId) {
gs.info('sysid ' + sysId);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', sysId);
//gr.addExtraField('group.type','itil');
gr.query();
var arr = [];
while (gr.next()) {
if (gr.group.type.indexOf(gs.getProperty('SysId.itil.type')) > -1 ) //created a system property SysId.itil.typeand stored type itil backend sys id
{
gs.info('type', gr.group.type);
gs.info('inside if');
arr.push(gr.getValue('group'));
}
}
gs.info('arra' + arr.toString());
if (arr.length == 0) {
gs.info('inside false side');
return 'sys_idIN' + '';
} else {
return 'sys_idIN' + arr.toString();
}
},
type: 'getAssignedToGroup'
});
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 01:02 PM
This works perfectly! Thank you so much!