Question on Scheduled Job

Community Alums
Not applicable

Hi,

I have a scenario where if the incidents are in onHold State and Assigned to is empty even though the incidents opened a week ago. I am making the state of those incidents resolved. I have completed the script, but there is an issue. The incidents are not updated to resolved.

 

1.png

 

2.png

 

3.png

 

var gr = new GlideRecord("incident");
gr.addEncodedQuery("active=true^assigned_toISEMPTY^opened_atRELATIVELT@dayofweek@ago@7^state=3");
gr.query();
while(gr.next()){
	gs.log("entering script");
	gr.setValue("state", 6);
	gr.close_code("Known error");
	gr.close_notes("Scheduled job from Suman");
	gs.log("Scheduled job from Suman");
	gr.update();
}

 

Regards

Suman P.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

can you try this?

var gr = new GlideRecord("incident");
gr.addEncodedQuery("active=true^assigned_toISEMPTY^opened_atRELATIVELT@dayofweek@ago@7^state=3");
gr.query();
while(gr.next()){
	gs.log("entering script");
	gr.setValue("state", 6);
	gr.close_code = "Known error";
	gr.close_notes = "Scheduled job from Suman";
	gs.log("Scheduled job from Suman");
	gr.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi @Community Alums 
You might forget to add .setValue()

var gr = new GlideRecord("incident");
gr.addEncodedQuery("active=true^assigned_toISEMPTY^opened_atRELATIVELT@dayofweek@ago@7^state=3");
gr.query();
while(gr.next()){
	gs.log("entering script");
	gr.setValue("state", 6);
	gr.close_code("Known error");
	gr.close_notes("Scheduled job from Suman");
	gs.log("Scheduled job from Suman");
	gr.update();
}

 


Thanks and Regards,

Saurabh Gupta

Community Alums
Not applicable

Thank you. I made this blunder.