Find Out Active RITMs and related tasks are closed using Scheduled jobs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 11:33 PM - edited 04-23-2024 11:42 PM
Hi Team,
I got one requirement where I need to show the RITMs record, which are not closed but their related Task( sc_task,change or approval etc). are closed.
And I have to do this using scheduled jobs.
Anyone have any idea on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 12:00 AM
Hi @priyanka1028 ,
I tried your problem in my PDI and It works for me please use below code
var gr = new GlideRecord('sc_task');
gr.addQuery('state=3');
gr.query();
while(gr.next()){
gs.print('Task Number = ' + gr.number + " State = " + gr.state + " Parent = " + gr.parent.getDisplayValue());
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery('stateNOT IN3,4,7');
ritmGr.addQuery('sys_id', gr.parent);
ritmGr.query();
if(ritmGr.next()){
gs.print('Number = ' + ritmGr.number + " State = " + ritmGr.state);
}
}
You can create Scheduled job and it would be scripted type and you can give the when to run conditions .
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 12:13 AM
After creation of scheduled job, will it display the RITMs.
If yes, then where can I able to see the data?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 12:16 AM
Hi @priyanka1028 ,
It will not display the RITM, it gives you that RIMT that are not closed but there sc_task are closed. If you want you can close them by that given script.
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak