I want to cancel a Problem record through script.

ShaikS881020266
Tera Contributor

Hi experts,

I want to cancel a "Problem records" through script. 

Please suggest a solution for this.

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @ShaikS881020266 

 

check this

 

https://www.servicenow.com/community/developer-forum/how-to-close-a-problem-record-ticket-using-back...

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]

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

Community Alums
Not applicable

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 

SarthakKashya2_0-1713871781771.png

 

 

Please mark my answer correct and helpful if this works for you 

 

Thanks and Regards 

Sarthak