Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Mass close Remediation Tasks

mattystern
Kilo Sage

Hi all,

We have around 62000 remediation tasks which all need to be closed. I first tried using "update all" to update their "state" values to "closed completed." However, this times out and only closes around 3000 records before timing out. So next, I tried to run a background script where I use an EncodedQuery on the task table, but in Dev, my background script was timing out (reached 4 hours) and did not close all records. Is there a way to identify which business rule(s) or script(s) are taking a long time to process? Are there places I should check to make sure there aren't going to be spam notifications to the fulfillment team?

Thanks for any advice!

1 ACCEPTED SOLUTION

chrismcdevi
ServiceNow Employee

Hi,

 

Ideas...

  • Do this in smaller chunks
  • Put this in a Fix Script so it can run longer
  • Use gr.setworkflow(false) to stop the Business Rules from running on the Remediation Task table
    • Then use the "Auto-Close Vulnerable Items" to close the VITS

 

 

View solution in original post

9 REPLIES 9

Hi @jremt 

 

I think this would work in a background script/fix script! Just make sure to use this line on your glide record:

gr.setworkflow(false)

jremt
Tera Contributor

i'm not a developer in SNOW. Is there a way on the UI that I can do it?

From the Remediation Task List view, you can edit the Assignment group field my selecting it, changing it and then clicking the green check mark.

MartinDewit_0-1696593564773.png

 

For selection of multiple you can CTRL + Click and drag. This will updated multiple records at the same time, see below 5 records

MartinDewit_1-1696593585706.png

 

AshishKM
Kilo Patron

Hi, 

You can use the updateMultiple() method with result set object, like below.

gr.setworkflow(false)
gr.updateMultiple();

 

Thanks,

Ashish


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Liju John
Tera Expert

Execute a fix script that runs in the background

/*You can close the Vulnerable Items*/
var chgMgr = new sn_vul.VulnerabilityStateChangeManager();
var vul = new GlideRecord('sn_vul_vulnerable_item');
vul.addEncodedQuery('active=true^last_foundRELATIVELE@dayofweek@ago@14');
vul.query();
while (vul.next())
{
var desired_state = 3;
var substate = 4;
var close_notes = "Auto-Closed by vr.system as the scanner did not report this vulnerability for more than 14 days.";
chgMgr.handleStateChangeRequest(vul, desired_state, substate, close_notes);
vul.update();
}

 

/* Remediation Tasks closing */

var gr = new GlideRecord("sn_vul_vulnerability");
gr.addEncodedQuery('active=true');
gr.query();
while (gr.next()){
gr.state = 3;
gr.work_notes = gs.getMessage("Auto-Closed by vr.system as the scanner did not report this vulnerability for more than 14 days");
gr.setworkflow(false)
gr.update();
}