Changing the Assignment group of List of Incidents which are in closed state

Black Coder
Tera Guru

There is a list of incidents which are in Closed state. We are in a situation to change the assignment group of all those incidents without changing any group. But right now when we try to change the group for those closed incidents, the state is also changed to "New" state.

 

What is the approach we have to follow in order to change only the assignment group of closed incidents without changing any other fields?

 

1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@Black Coder  There  must be some custom business rule or client script which is changing status of incident record to New state. But we are using "grIncident.setWorkflow(false)" in our script which will prevent execution of any business rule or client script. 

 

To replicate this issue, I created custom business rule which is changing the status of incident record from "Closed" to "New" when assignment group changes

 

SANDEEP28_0-1690787307424.png

 

SANDEEP28_1-1690787346218.png

 

I ran below code without setWorkflow(false), then it changed state of incident to New because business rule got executed

 

var grIncident = new GlideRecord('incident');
if (grIncident.get('470af5afa9fe198101b324dd773ef379'))  //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.update();
}

SANDEEP28_2-1690787538870.png

 

I ran below code with setWorkflow(false), then it does not changed state of incident to New because business rule didn't executed

 

var grIncident = new GlideRecord('incident');
if (grIncident.get('e329de99731423002728660c4cf6a73c'))  //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.setWorkflow(false);
grIncident.update();
}

SANDEEP28_3-1690787744196.png

 

Could you please share screenshot of script which you are executing

 

 If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

 

 

View solution in original post

5 REPLIES 5

SANDEEP28
Mega Sage

@Black Coder You can use background script to achieve this.

Run below query for multiple records 

var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery('numberININC0000050,INC0009004,INC0000601^state=7');  // create encoded query from incident list view and put it here
grIncident.query();
while (grIncident.next()){
grIncident.setValue('assignment_group', '8a5055c9c61122780043563ef53438e3', 'Hardware'); //put the sys id and display value of assignment which you want to update
grIncident.setWorkflow(false);   
grIncident.update();
}

 Run below query for single record to test

 

var grIncident = new GlideRecord('incident');
if (grIncident.get('ef43c6d40a0a0b5700c77f9bf387afe3'))  //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.setWorkflow(false);
grIncident.update();
}

 If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

Black Coder
Tera Guru

I tried with above script you have shared. The issue is when I ran this script to change the group, it changed the state of an incident from Closed to a New state too.

Here I should not update the state and have to keep as Closed state

SANDEEP28
Mega Sage

@Black Coder  There  must be some custom business rule or client script which is changing status of incident record to New state. But we are using "grIncident.setWorkflow(false)" in our script which will prevent execution of any business rule or client script. 

 

To replicate this issue, I created custom business rule which is changing the status of incident record from "Closed" to "New" when assignment group changes

 

SANDEEP28_0-1690787307424.png

 

SANDEEP28_1-1690787346218.png

 

I ran below code without setWorkflow(false), then it changed state of incident to New because business rule got executed

 

var grIncident = new GlideRecord('incident');
if (grIncident.get('470af5afa9fe198101b324dd773ef379'))  //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.update();
}

SANDEEP28_2-1690787538870.png

 

I ran below code with setWorkflow(false), then it does not changed state of incident to New because business rule didn't executed

 

var grIncident = new GlideRecord('incident');
if (grIncident.get('e329de99731423002728660c4cf6a73c'))  //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.setWorkflow(false);
grIncident.update();
}

SANDEEP28_3-1690787744196.png

 

Could you please share screenshot of script which you are executing

 

 If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

 

 

Black Coder
Tera Guru

Thanks It resolved my issue @SANDEEP28