
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 03:59 AM
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.
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:42 AM
@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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:54 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:57 AM
Thank you. I made this blunder.