RITM Records with Scheduled Jobs and Event

priyanka1028
Tera Contributor

Hi Team,

 

I have one requirement where I need to show the RITMs which are not closed but Related tasks are closed.

I need to do this by using scheduled jobs and event.

Is it possible to send report of this data using scheduled jobs and event.

If yes, How to proceed with this?

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @priyanka1028 ,

I tried your problem in my PDI and I hope you need something like this 

I created Scheduled job - I called one event over there please check script and image for reference 

SarthakKashya2_0-1713952747735.png

 

 

var ritmArr = [];
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);
		ritmArr.push(ritmGr.getValue('number'));
		gs.eventQueue('showRITMNumber', ritmGr, ritmArr, gr.getValue('number'));
	}
}

 

I created notification when event triggered 

 

Here I'm calling parm 1 and parm2 

SarthakKashya2_1-1713952816270.png

 

Than I got the email with open RITM number

 

SarthakKashya2_2-1713952878498.png

 

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

 

Thanks and Regards 

Sarthak

View solution in original post

1 REPLY 1

Community Alums
Not applicable

Hi @priyanka1028 ,

I tried your problem in my PDI and I hope you need something like this 

I created Scheduled job - I called one event over there please check script and image for reference 

SarthakKashya2_0-1713952747735.png

 

 

var ritmArr = [];
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);
		ritmArr.push(ritmGr.getValue('number'));
		gs.eventQueue('showRITMNumber', ritmGr, ritmArr, gr.getValue('number'));
	}
}

 

I created notification when event triggered 

 

Here I'm calling parm 1 and parm2 

SarthakKashya2_1-1713952816270.png

 

Than I got the email with open RITM number

 

SarthakKashya2_2-1713952878498.png

 

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

 

Thanks and Regards 

Sarthak