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

Community Alums
Not applicable

Thank you, possibly your incident module is configured differently. Thank you for trying.

Regards

Suman P.

Hi @Community Alums 

 

I am using OOTB, can i ask you , give a try to resolve Incident from On Hold and see is it working or not. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

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

Community Alums
Not applicable

Thank you @Ankur Bawiskar , it worked well. But, why can't I use setValue. Oh God. I forgot to use setValue

Regards

Suman P.

@Community Alums 

Glad that it worked.

that's correct you were setting the field value in wrong manner.

it was quite simple to point out.

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