background script to close bulk sctasks

Swathi KC
Tera Contributor

Hi All,
Could you please help me to close bulk tasks from background scripts. is there any script available.
Ex : TASK0012345678

Thank you in Advance.

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Swathi KC 

 

You can do via list view as well. 

 

https://www.servicenow.com/community/service-management-forum/bulk-close-1200-incidents/m-p/421682/p...

 

https://www.servicenow.com/community/developer-forum/how-to-bulk-close-incidents/m-p/2123592

*************************************************************************************************************
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]

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

SN_Learn
Kilo Patron
Kilo Patron

Hi @Swathi KC ,

 

A sample background Script:

var grTask = new GlideRecord('task');
grTask.addQuery('number', 'TASK0001002');
grTask.setLimit(1);
grTask.query();
if(grTask.next()) {
    grTask.setValue('active', false);
    grTask.update();
}

 

For Bulk tickets:

var grTask = new GlideRecord('task');
grTask.addQuery('number', 'IN', 'TASK0001001,TASK0001002,TASK0001003');
grTask.query();
grTask.setValue('active', false);
grTask.updateMultiple();

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.