- 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-20-2021 10:46 AM
Hi
As per servicenow functionality if you have to populate reference field then you have provide/send its sys id only there is not other way.
Please mark the answer Helpful and Correct If applicable
Best Regards
Himanshu Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2021 10:47 AM
assignment_group is a refernce field so mapping with sys_id of group is recomended.
if you already have names and want to map then use this code to get sys_id of group.
var group= '';//give default sys_id if group is not found.
var gr=new GlideRecord('sys_user_group');
if(gr.get('name','group_name'))
group = gr.sys_id; //mapping sys_id based on group name.
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-20-2021 01:40 PM
This worked, thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2021 01:28 PM
You should be able to do vg.setDisplayValue('assignment_group','abc');
I don't think that 2 hours to update 150k records is poor performance if I am honest thats over 1200 records per minute. As this is a fix script you aren't going to run it often so I would just run it in a maintenance window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2022 07:19 AM