Find Out Active RITMs and related tasks are closed using Scheduled jobs

priyanka1028
Tera Contributor

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?

3 REPLIES 3

Community Alums
Not applicable

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 .

SarthakKashya2_0-1713942010840.png

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak

After creation of scheduled job, will it display the RITMs.

If yes, then where can I able to see the data?

Community Alums
Not applicable

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