I want to cancel a Problem record through script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 02:54 AM
Hi experts,
I want to cancel a "Problem records" through script.
Please suggest a solution for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 04:05 AM
check this
and modify as per need.
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
04-23-2024 04:28 AM - edited 04-23-2024 04:31 AM
Hi @ShaikS881020266 ,
I tried your problem in my PDI and get to know like we can not close problem in New state to close state directly, if you want to close the problem it should be in Resolved state I'm adding the script below refer. There are some mandatory fields when we close the problem as I mentioned below like - Assigned to, Resolution Code, Fix Notes and Cause Notes
var gr = new GlideRecord('problem');
gr.addQuery('sys_id', '04ce72c9c0a8016600b5b7f75ac67b5b');
gr.query();
if(gr.next()){
gr.setValue('state', 107);
gr.assigned_to = 'be05e21b937331100d5170918bba10c7';
gr.resolution_code = 'fix_applied';
gr.fix_notes = 'Test';
gr.cause_notes = 'Test';
gr.update();
}
Adding image for reference
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak