Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Question on Scheduled Job

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

@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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Saurabh Gupta
Kilo Patron

Hi,
Instead of creating a scheduled job create a scheduled flow to do the same job without writing any code.

 

 

 


Thanks and Regards,

Saurabh Gupta

Dr Atul G- LNG
Tera Patron

Hi @Community Alums 

 

It will not, As per OOTB,

 

LearnNGrowAtul_0-1702900923849.png

 

 

These are mandatory and if you are resolving the incident via script, make sure these values also get populated. 

*************************************************************************************************************
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/dratulgrover [ Connect for 1-1 Session]

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

Not applicable

Hi @Dr Atul G- LNG ,

The backend values for resolution Code and Resolution notes are close_code, and close_notes respectively.

gr.close_code("Known error");
gr.close_notes("Scheduled job from Suman");

Regards

Suman P.

Hi @Community Alums 

 

I tried manually and got this error

 

LearnNGrowAtul_0-1702902446762.png

 

*************************************************************************************************************
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/dratulgrover [ Connect for 1-1 Session]

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