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

SN_Learn
Mega 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.