How to update 100 incidents records at a time with different assignment group

sahana1998
Tera Contributor

I want to update 100 incident records at a time with different assignment group .

is there any option to update .

Can any one please help on this.

7 REPLIES 7

Dnyaneshwaree
Mega Sage

Hello @sahana1998 ,

Create a Scripted Action or fix script to update the records. For example:

 

(Replace 'sys_id1,sys_id2,...' with the actual sys_ids of the incidents and 'new_assignment_group_sys_id' with the sys_id of the new assignment group.)

 

var gr = new GlideRecord('incident');
gr.addQuery('sys_id', 'IN', 'sys_id1,sys_id2,...');
gr.query();
while (gr.next()) {
    gr.assignment_group = 'new_assignment_group_sys_id';
    gr.update();
}

 

 



Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Mark Manders
Mega Patron

What do you want to update? Do you have 100 incidents with different assignment groups that you need to update, or do you need to update 100 incidents to different assignment groups?

For both goes: can you make the select for these 100? If you can and you need to perform the same update, you can use 'update all' after you have put the correct filter on your list. If the updates are different, you will need to apply your update logic through a script (either background script if it's a one time thing, or fix script if you need to perform it more often).


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Weird
Mega Sage

Yes, but you need to write a script.
You can for example search navigation for "background" and open script - background (or something like that) to run code like BR's. Or you can create a fix script etc to run a script of your choosing. There are

Anyway, you just need to define how the groups are updated.
Here's an example code where we define all incidents that need to be updated as a comma separated list of "numbers" on "allInc" variable. The value would look like "INC0001,INC0002,INC0003".
Then we define incidents that will be updated with certain groups on other variables.

The script will first get all incidents defined in "allInc". Then it will loop them and check if the current loop's incidents is listed on either (or more) of the defined "groupXInc" variables and will do a specific update on them.
Here you could write more logic, but I think this is relatively clear.

 var allInc = "INC0001,INC0002,INC0003"; //This can be a comma separated list of all incidents to be updated
var groupOneInc = "INC0001,INC0002"; //Similarly incidents with one group
var groupTwoInc = "INC0003"; //Incidents with the other group

var incident = new GlideRecord('incident');
incident.addQuery("numberIN" + allInc); //First get all incidents listed in allInc variable.
incident.query();
while(incident.next()){
var number = incident.number.toString();
if(groupOneInc.indexOf(number) > -1){
//Run this if for incidents that are listed in variable groupOneInc
incident.assignment_group = "XXX";
}else if(groupTwoInc.indexOf(number) > -1){
//Run this for the other
incident.assignment_group = "YYY";
}else{
//If the first if and else if didn't match, then this is ran.
//note that you can have multiple else if's.
}
incident.update();
}

 There are other ways to do this, but this is quite a simple script for it.
If you have more details on how you know which incidents to update and with what values I can try to make it more precise.

sahana1998
Tera Contributor

Is there any simple way to update without scripting ?