Automatically assigning ticket to myself, if the ticket is not assigned to anybody

Gowtham29
Tera Expert

Hi all,

I have a requirement such as, If the ticket is not assigned to anybody with in four hours based on created time then the ticket needs to be get auto assigned to myself.

For example, My assignment group name is service desk group and along with me in that group five members exist. Now ticket is assigned to my group on today. Now after four hours if the ticket is not assigned to any person in my group then it should auto assign to my name. This should be happen only for catalog task(sc_task) tickets.

please help me in this regard. Thank you in advance.

9 REPLIES 9

arielgritti
Mega Sage

Hello

In our case I have a custom Script Include and a scheduled job running every minute to assign in a round robin way the ticket without assigned_to technician.

The jobs configuration is: 

find_real_file.png

You can create your own Script Include with your "logic" to achieve this requeriment

 

Please, mark correct, useful or bookmark if I helped you

Thanks

Ariel

 

HI Ariel,

Thanks for the response, can you please extend your help by suggesting me how to create script include based upon the requirement here? Kindly help. Thank you 

 

Hello

Yes, of course.

Mi script include script is this:

var GLOIncidentUtil = Class.create();
GLOIncidentUtil.prototype = {
	initialize: function() {
	},
	
	/*
	Query the incident table without assigned_to tech of the groupIN parameter
	and assign one using round robin algoritm
 	*/
	roundRobinTechIncident: function(groupIN)
	{
		//Incidents without assigned_to tech
		var grINC = new GlideRecord("incident");
		grINC.addQuery('assignment_group', groupIN);
		grINC.addQuery('assigned_to','');
		grINC.query();
		
		//loop
		while (grINC.next()) {
			//Tech round robin pool
			var group = new GlideRecord('sys_user_grmember');
			group.addQuery('group', groupIN);
			group.addQuery('user.u_round_robin_active',true);
			group.orderBy('user.u_last_ticket_assigned');
			group.query();
			
			//Assigned Tech
			if (group.next()) {
				//Update round robin tech data
				var nowdt = gs.nowDateTime();
				var updateDate = new GlideRecord('sys_user');
				updateDate.addQuery('sys_id', group.user);
				updateDate.query();
				
				while(updateDate.next())
					{
					updateDate.u_last_ticket_assigned = nowdt;
					updateDate.update();
				}
			
				//Incident update
				grINC.comments = 'Incidencia asignada de forma automática por ServiceNow al técnico: ' + group.user.name;
				grINC.assigned_to = group.user;
				grINC.u_round_robin_assigned = true;
				grINC.update();
			}
		}
	},
	
	type: 'GLOIncidentUtil'
};

 

Ariel

Your script include must be similar to this

var GLOIncidentUtil = Class.create();
GLOIncidentUtil.prototype = {
	initialize: function() {
	},
	
	/*
	Query the incident table without assigned_to tech of the groupIN parameter
	and assign one using round robin algoritm
 	*/
	roundRobinTechIncident: function(groupIN)
	{
		//Incidents without assigned_to tech
		var grINC = new GlideRecord("incident");
		grINC.addQuery('assignment_group', groupIN);
		grINC.addQuery('assigned_to','');
		grINC.query();
		
		//loop
		while (grINC.next()) {
			//Assign me
			grINC.assigned_to = '<<YOUR-USER-SYS_ID>>'
			grINC.update();
		}
	},
	
	type: 'GLOIncidentUtil'
};

 

You must call your script include with the "Service Desk" SYS_ID


Ariel