- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2021 09:30 AM
Hi,
I have this fix script to fix unassigned tickets with an assignment group. I have like around 150k records to update, but my script gets timed out.
I tested with 1k records which worked but dealing with huge number my script isn't efficient enough, any thoughts?
runit();
function runit() {
var vg = new GlideRecord('sn_vul_vulnerability');
vg.addEncodedQuery('assignment_group.nameISEMPTY^vulnerability_group_rule=2d8025e41b887c102cc9975f034bcb67^ORvulnerability_group_rule=2ad2fb201bdf6410151c975f034bcb07^ORvulnerability_group_rule=ce9ca1f8db3bdc1090d359e5ca961959^ORvulnerability_group_rule=b0548ab0db3ee4508785dc62ca961942^ORvulnerability_group_rule=5965adc2dbf3985090d359e5ca9619fa^ORvulnerability_group_rule=3ff5f021dbb33fc4399475e6f4961983');
vg.query();
while (vg.next()){
vg.setValue('assignment_group', '6bffdcf8dbe2f41813c6dff648961975');
vg.updateMultiple();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2021 09:38 AM
Hi
yes fix scripts are not capable to proceed with huge records you try scheduled job for the same it will work for you
Put logs as well in scheduled job so that you will get the information of number of records processed and time taken.
Please mark the answer Helpful and correct if applicable
Best Regaards
Himanshu Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2021 09:38 AM
Hi
yes fix scripts are not capable to proceed with huge records you try scheduled job for the same it will work for you
Put logs as well in scheduled job so that you will get the information of number of records processed and time taken.
Please mark the answer Helpful and correct if applicable
Best Regaards
Himanshu Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2021 09:18 AM
Hi
is your issue is resolved and if yes then can you please mark the response helpful and correct
Best Regards
Himanshu Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2021 10:01 AM
Hi, Modify like below.
use vg.setLimit(1000); before vg.query(); which lets you to limit the number of gliderecord that returns after satisfying the gliderecord condition.
runit();
function runit() {
var vg = new GlideRecord('sn_vul_vulnerability');
vg.addEncodedQuery('assignment_group.nameISEMPTY^vulnerability_group_rule=2d8025e41b887c102cc9975f034bcb67^ORvulnerability_group_rule=2ad2fb201bdf6410151c975f034bcb07^ORvulnerability_group_rule=ce9ca1f8db3bdc1090d359e5ca961959^ORvulnerability_group_rule=b0548ab0db3ee4508785dc62ca961942^ORvulnerability_group_rule=5965adc2dbf3985090d359e5ca9619fa^ORvulnerability_group_rule=3ff5f021dbb33fc4399475e6f4961983');
vg.query();
vg.setValue('assignment_group', '6bffdcf8dbe2f41813c6dff648961975');
vg.updateMultiple();
}
or
runit();
function runit() {
var vg = new GlideRecord('sn_vul_vulnerability');
vg.addEncodedQuery('assignment_group.nameISEMPTY^vulnerability_group_rule=2d8025e41b887c102cc9975f034bcb67^ORvulnerability_group_rule=2ad2fb201bdf6410151c975f034bcb07^ORvulnerability_group_rule=ce9ca1f8db3bdc1090d359e5ca961959^ORvulnerability_group_rule=b0548ab0db3ee4508785dc62ca961942^ORvulnerability_group_rule=5965adc2dbf3985090d359e5ca9619fa^ORvulnerability_group_rule=3ff5f021dbb33fc4399475e6f4961983');
vg.query();
while (vg.next()){
vg.setValue('assignment_group', '6bffdcf8dbe2f41813c6dff648961975');
vg.update();
}
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2021 12:19 PM
run in background script with no cancel checkbox unchecked.