How to resolve multiple incidents in one go?

Ujjwala1
Tera Contributor

Hi experts,

We got a request from one of our clients to resolve all the tickets which are in state new with specific close codes and notes,also with work notes? also want to update some fields on incident form 

Before resolving he wants to assign all those tickets to one ITIL user 

I have been trying to create one fix script for that but I am not sure whether it will help me or not 

Is there any way I can fulfill this type of requirement?

Fields need to be updated :
Item - 
Incident State - New
Impact and urgency - 3 medium
Assigned to - 
Close code - permanant
Close Notes - 
Work notes-

 

Additional comment-



Any kind of help is greatly appreciated! 

Thank you 

Ujjwala 

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi,

 

you can try the below script for bulk closure.

bulkClosure();

function bulkClosure(){

	var inc = new GlideRecord('incident');
	inc.addEncodedQuery('add-your-query-here');
	inc.query();
	while(inc.next()){


		inc.incident_state = '6'; // resolved
		inc.active = 'false';
		inc.cmdb_ci= 'add ci name here'; 
		inc.impact = '3';
		inc.urgency = '3';
		inc.assigned_to ='sys_id-of -assigned-users'; 
		inc.close_code = 'permanant';
		inc.close_notes ='closed notes'; 
		inc.work_note = "add work notes here";
		inc.comments = 'add additional comments here';
		inc.setWorkflow('false');
		inc.autoSysFields('false');
		inc.update();

	}

	gs.info("resolved: " + inc.getRowCount());
}

 

Regards,

Sagar Pagar

The world works with ServiceNow

View solution in original post

2 REPLIES 2

Sagar Pagar
Tera Patron

Hi,

 

you can try the below script for bulk closure.

bulkClosure();

function bulkClosure(){

	var inc = new GlideRecord('incident');
	inc.addEncodedQuery('add-your-query-here');
	inc.query();
	while(inc.next()){


		inc.incident_state = '6'; // resolved
		inc.active = 'false';
		inc.cmdb_ci= 'add ci name here'; 
		inc.impact = '3';
		inc.urgency = '3';
		inc.assigned_to ='sys_id-of -assigned-users'; 
		inc.close_code = 'permanant';
		inc.close_notes ='closed notes'; 
		inc.work_note = "add work notes here";
		inc.comments = 'add additional comments here';
		inc.setWorkflow('false');
		inc.autoSysFields('false');
		inc.update();

	}

	gs.info("resolved: " + inc.getRowCount());
}

 

Regards,

Sagar Pagar

The world works with ServiceNow

Hi @Sagar pagar ,

The script worked out for me, Thank you very much!