Fix script for update the assignment group to original assignment group

Barathk
Tera Contributor

Hi All,

Fix script for update the assignment group to original assignment group.
I have created new field as original assignement group and created a BR for update the assignment group details to the original assignment group.

data updating fine after creating the BR for new sctasks.

I want to update the old task as well , can anyone please help for the fix script to update the assignment group to the original assignment group.

I want to update the first assignment group what ever when ticket is created.

3 REPLIES 3

Brad Bowman
Kilo Patron

Something like this will update the assignment group with the original assignment group on all Catalog tasks where they do not match and original is populated:

//return all sc_task records where the asignment group is not the same as the original assignment group, and the original assignment group is not empty 
var sctask = new GlideRecord('sc_task');
sctask.addQuery('assignment_group', '!=', 'u_original_assignment_group'); //use your custom field name
sctask.addQuery('u_original_assignment_group', '!=', '');
sctask.query();
while (sctask.next()) {
	//set the assignment group to the original assignment group - or whatever you're trying to do
	sctask.assignment_group = sctask.u_original_assignment_group;
	sctask.update();
}

Krushna R Birla
Kilo Sage

Hi @Barathk 

 

You can use below code, this will helps you to resolve your issue

Note : Please modify the field name as per your requirements

 

var sctask = new GlideRecord('sc_task');
sctask.addNullQuery('u_original_assignment_group'); // Query records where u_original_assignment_group is null
sctask.addNotNullQuery('assignment_group'); // Query records where assignment_group is not null
sctask.query();
while (sctask.next()) {
    sctask.u_original_assignment_group = sctask.assignment_group;
    sctask.setWorkflow(false);
    sctask.update();
}

 

This will definitely helps you to resolved your issue.

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

 

Best Regards,
Krushna Birla

Hi,
above script is fine for getting current assignment group , but I want to update the first assignment group what ever when ticket is created.