- 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:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:02 AM
Hi @Community Alums
It will not, As per OOTB,
These are mandatory and if you are resolving the incident via script, make sure these values also get populated.
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:21 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 04:27 AM
Hi @Community Alums
I tried manually and got this error
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]
****************************************************************************************************************