- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 02:39 AM
Hi all,
When I create a report for any of the ITSM Tables (e.g: Incident, Problem, Request or Change).Then I can use the script to show any records that are assigned to active groups with zero members.
I have written the script in task table and grpmember table to retrieve the data.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 10:49 AM
var groupsWithoutMembers = [];
var list = new GlideRecord("sys_user_group");
list.addEncodedQuery("active=true^RLQUERYsys_user_grmember.group,=0,m2m^ENDRLQUERY");
list.query();
while (list.next()) {
groupsWithoutMembers.push(list.sys_id + "");
}
var taskGR = new GlideRecord("task");
taskGR.addQuery("sys_class_name", "incident");
taskGR.addQuery("assignment_groupIN" + groupsWithoutMembers);
taskGR.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 09:35 AM
Hello @Suvedha Vignesh ,
You can try the below code once.
var record =[];
var tsk = new GlideAggregate('task');
tsk.addEncodedQuery('sys_class_name=incident^ORsys_class_name=problem^ORsys_class_name=change_request^ORsys_class_name=sc_task^assignment_groupISNOTEMPTY^active=true^assignment_group.active=true');
tsk.groupBy('assignment_group');
tsk.addAggregate("COUNT");
tsk.query();
while (tsk.next()) {
// gs.print(tsk.getAggregate('COUNT')+' ' + tsk.getDisplayValue('assignment_group'));
var team = new GlideAggregate("sys_user_grmember");
team.addEncodedQuery("group=" + tsk.assignment_group);
team.addAggregate("COUNT");
team.query();
if(team.next())
{
// gs.print(team.getAggregate("COUNT"));
var counts =team.getAggregate("COUNT") ;
if(counts == 0)
{
var task = new GlideRecord('task');
task.addEncodedQuery('sys_class_name=incident^ORsys_class_name=problem^ORsys_class_name=change_request^ORsys_class_name=sc_task^assignment_groupISNOTEMPTY^active=true^assignment_group.active=true');
task.addQuery('assignment_group',task.assignment_group); // Here is the error earlier in your code.
task.query();
if(task.next())
{
record.push(task.number);
}
}
}
}
gs.print(record);
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-07-2024 07:40 PM
Hi Appanna,
Thank you for the reply, It is now working .
Thanks,
Suvedha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2024 07:41 PM
Hi Appanna,
Thank you for the reply.
It is not working,
Thanks,
Suvedha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 10:10 AM
Hi Suvedha
Could you please elaborate the problem statement with screen shot
Regards
Regards,
Prasanna