count the number of catalog tasks in a request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2016 08:35 AM
I have read through all of this post How to count the number of task assigned to a request number ? and the original request was for a count of the number of requested items; I am trying to figure out the proper code for a count of the number of catalog tasks. Can someone help me with this please! I am running out of time on this and my boss is getting antsy.
I have been testing this background scripts and it keeps giving me 31 active tasks - the total # of active tasks, which tells me it's accessing the right table. But when I transfer it to my display BR, based on the post, it's returning "Tasks: 0" every time, why?
var taskItems = new GlideAggregate('sc_task');
taskItems.addQuery('task','c4288fd50a0a0b1200577058fffbf9a3'); //Request sys_id for RITM0000010
taskItems.addAggregate('COUNT');
taskItems.addActiveQuery(); //only counts the active items
taskItems.query();
if (taskItems.next()) {
gs.print('Tasks: ' + taskItems.getAggregate('COUNT'));
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2016 06:21 AM
Sorry, not at the moment, sitting at home with alot of kids and kids friends running around.
But after reading the post above, I know the problem.
Its just like you say, its the "current.sys_id" that is messing with you.
When your BR is on sc_request current.sys_id is the sys_id of the request that you are looking at.
when you change your BR to sc_task and click on a catalog task the "current.sys_id" is the sys_id of that task and therfor it doesnt work.
Give a couple of minutes to think and I think we can sort this out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2016 06:08 AM
Add me on linked in and you'll see an update there whenever I put up a new blog post
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2016 05:31 AM
Ok, so when I replace the current.sys_id with a Request sys_id I get what I would expect...
Background message, type:info, message: Requested Items: 1
Background message, type:info, message: Tasks: 2
I am running this from a ServiceNow demo instance, if that helps. I will keep poking away at it, the weird thing I keep coming back to is that this works when the BR is pointing to the Catalog Request [sc_request] table, but not the Catalog Task [sc_task]. It's like it doesn't know how to go up the chain...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2016 05:39 AM
So I tried the same thing in our Development instance thinking maybe my Demo instance is messed up, but I got the same result - 0's.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2016 05:44 AM