Getting a true "first contact SLA" stop condition

amarks
Tera Expert

Hi folks,

 

I'm looking to have a stop condition on an SLA based on the actual comment to the requester. It is my understanding (although please correct me if I'm wrong) that the default stop state for First Contact Resolution is when the request is assigned to an agent/technician. However, to our organization, that metric is the "time to assigned" and not the "first contact."

 

Considerations:

Assigned but with no response to the requester will generate an inaccurate report.

Response without assignment will generate an inaccurate report.

 

Is there presently a way to set a stop condition to when the Comment is sent to the requester?  Has anyone else had to work around this limitation?

 

Thanks,

Adam

1 REPLY 1

tharun_kumar_m
Mega Guru

Hi Amarks,

 

The best/recommended way to do this is, In the start condition of the SLA definition you can remove the condition "Assignment group is not empty" and add "Assigned to is not empty". 

 

But you can achieve your requirement by DOM (which is not recommended by ServiceNow).

 

Client Script:

Type: OnLoad, isolate script: false

function onLoad() {
//g_form.addInfoMessage("out");
//var assignedto = g_form.getValue('assigned_to');

    if (g_form.getValue('assigned_to') == g_user.userID) {

		document.addEventListener('DOMContentLoaded', function() {
		// Select the post button by its class name
		var postButton = document.querySelector('.activity-submit');

		if (postButton) {
			postButton.addEventListener('click', function(event) {
				// DOM manipulation
				// script include
					var taskSysId = g_form.getUniqueValue();
					var ga = new GlideAjax('StopIncidentSLA'); //script include to stop SLA
					ga.addParam('sysparm_name','voidStopIncidentSLA');
					ga.addParam('sysparm_task_sysid',taskSysId);
					ga.getXMLAnswer(stopIncidentSLA);
			});
		}
		});
	}
}
function stopIncidentSLA(response) {
	if(response){
		//g_form.addInfoMessage(response.toString());
		g_form.addInfoMessage("SLA is stopped");
	}
}

 

Script Include:

Name: StopIncidentSLA, Client callable: true

var StopIncidentSLA = Class.create();
StopIncidentSLA.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	voidStopIncidentSLA: function(){

		var taskSysId = this.getParameter("sysparm_task_sysid");

		var gdt = new GlideDateTime();

		var taskcomment	= new GlideRecord("task_sla");
		taskcomment.addQuery("task",taskSysId);
		taskcomment.setLimit(1);
		taskcomment.query();
		
		//gs.log("scriptincidentsla");
		
		if (taskcomment.next()) {
			gs.log(taskcomment.getValue("end_time"));
			if(taskcomment.getValue("end_time")==''){

				taskcomment.setValue("end_time", gdt.getValue());
				taskcomment.update();
			
			var result = {
				"result": "SLA Stopped"
			};
			return JSON.stringify(result);
			}
		}
	},
    type: 'StopIncidentSLA'
});

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.

 

Best regards,

Tharun Kumar