- 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:29 AM
Thank you, possibly your incident module is configured differently. Thank you for trying.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:31 AM
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]
****************************************************************************************************************
- 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:52 AM - edited 12-18-2023 04:58 AM
Thank you @Ankur Bawiskar , it worked well. But, why can't I use setValue. Oh God. I forgot to use setValue
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:13 AM
@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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader