- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 06:18 AM
I am trying to run a report on Requested Item that will show me the child Catalog Task. I know I can run it the opposite way with Catalog Task to show the parent RITM, but I don't want to run it that way.
I believe we have a problem in our system where we have RITM's with no Catalog Tasks being generated, so I am trying to capture that information. Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 06:24 AM
I dont think you could do this as a report. Your best bet would be to run a script that will return a list of RITM's that have no tasks. We used this in a similar situation:
var noTaskCounter = 0;
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('active=true^approval=approved'); //<-- Shows all RITMs that are approved and active - for us, these would be the ones that should have Tasks attached to them
gr.query();
while (gr.next()) {
//The below will check everything filtered above and find any that dont have any tasks attached
var tsk = new GlideRecord('sc_task');
tsk.addQuery('request_item', gr.sys_id);
tsk.query();
if (!tsk.next()) {
gs.info('RITM == {0} has Zero Tasks',gr.number);
noTaskCounter++;
}
}
gs.info('Out of {0} RITMs, only {1} had Zero Tasks', gr.getRowCount(), noTaskCounter);
Run this in Scripts - Background (On a sub production instance first) to see if it returns the results you need.
Let me know how you get on.
Harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 06:24 AM
I dont think you could do this as a report. Your best bet would be to run a script that will return a list of RITM's that have no tasks. We used this in a similar situation:
var noTaskCounter = 0;
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('active=true^approval=approved'); //<-- Shows all RITMs that are approved and active - for us, these would be the ones that should have Tasks attached to them
gr.query();
while (gr.next()) {
//The below will check everything filtered above and find any that dont have any tasks attached
var tsk = new GlideRecord('sc_task');
tsk.addQuery('request_item', gr.sys_id);
tsk.query();
if (!tsk.next()) {
gs.info('RITM == {0} has Zero Tasks',gr.number);
noTaskCounter++;
}
}
gs.info('Out of {0} RITMs, only {1} had Zero Tasks', gr.getRowCount(), noTaskCounter);
Run this in Scripts - Background (On a sub production instance first) to see if it returns the results you need.
Let me know how you get on.
Harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 06:42 AM
This is perfect, thank you.
Could you by chance help me change the script to show me ALL RITMS, not just active?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 06:47 AM
If you completely remove line 3 (which is the filter) that should then return all RITM's.
The script may take a while to run if there are a lot and could impact system performance while it is running so be careful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 07:42 AM
You are awesome! Thank you so much Harry!