- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 01:26 AM
Hey all
I have a customer who only wants to see a list report that gives only users who have closed less than 5 tasks over 30 days (All Tasks)
I see that there are limitations in the creation of a report and would like to hear from you experts how a script could be used for this and which I call via the report.
Thank you for your support.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 07:03 AM - edited ‎08-20-2023 07:09 AM
Hi @rosti ,
The issue is in the encoded query line in script include.
The encodedQuery should be link this:
and I have observed that in your script line there is javascript&colon.
gr.addEncodedQuery("closed_atONLast 30 days@javascript:gs.beginningOfLast30Days()@javascript:gs.endOfLast30Days()");
gr.addAggregate('COUNT', 'closed_by');
could you please make these changes.
this will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 10:13 AM
Hi @rosti ,
I have updated the script include If condition to check the fulfiller role. rest of the script is as it is.
if (gr.getAggregate('COUNT', 'closed_by') < 5) { // here we are checking aggregate count
var closesby = gr.closed_by.toString(); //Get closed by user i.e.user sys_id
var role = "itil"; // Here you can pass role called IT Service Management Professional.
var checkrole = gs.getUser().getUserByID(closesby).hasRole(role);// ckecking closed by user having fulfiller role
if (checkrole) { // if true then and then only push sys_if into array.
usersys.push('' + closesby);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 01:42 AM
Hi,
This can be achieved with related list conditions.
https://docs.servicenow.com/bundle/vancouver-platform-user-interface/page/use/using-lists-v3/task/cr...
Create a report for User table and use Task table related list for related list conditions.
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 04:00 AM
Something like this:
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 01:52 AM
Hi @rosti ,
You can use a Client Callable Script Include to get the sys_id of users who closed less than 5 tasks and you can call that in report filter condition. You can use the following method in ScriptInclude to get the user sys_ids of users with closed tasks less than 5.
getTasks: function(){
var gr = new GlideAggregate('task');
gr.addEncodedQuery('closed_atONLast 30 days@javascript:gs.beginningOfLast30Days()@javascript:gs.endOfLast30Days()');
gr.addAggregate('COUNT','assigned_to');
gr.query();
var users = [];
while(gr.next()){
if(gr.getAggregate('COUNT','assigned_to') < 5){
users.push(gr.assigned_to);
}
}
return users.join(',);
}
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2023 03:35 AM
Thanxs AnveshKumar M this
Do you have some time to give me a litle step by step guide how to set it up? or pointy me to some KB that could help me ?