Showing Business Elapsed Time from a SLA, as a percentage bar in a list?

Jacob Saaby Ni1
Giga Expert

Hi everyone.

So I want to achieve this: I want to be able to add the Business Elapsed Time as a column in a Case list (Or an Incident list, doesn't matter).

So that I see a column where the contents is a bar which shows how many % have elapsed, how many % are left before SLA breach.

Only problem is, it seems I can only go from task_sla to incident, not the other way around.

So I created a new field, a many to many relation etc. to try and bridge that gap. To no avail.

Any good ideas how I can show such a thing, in its own column, on say... the list of incidents?

3 REPLIES 3

Daniel203
Giga Contributor

Hi Jacob,

 

I’ve done something similar where I wanted to display the Business Elapsed Percent and Business Time Left as columns in a Catalogue Task list view. For this I did the following;

 

NOTE: This will only work is you have 1 SLA for each record. It doesn’t handle records with multiple SLA’s.

 

Step 1: Create a new reference field on the sc_task table.

  • Set it to reference the task_sla table.
  • Mine is called “Task SLA” (u_task_sla).
  • It doesn’t need to be visible on the form.

 

Step 2: Create a new server side script.

  • I’ve put mine in a Scheduled Job which I’ve set to run every hour. Code:
// declare variables.
var taskNum;
var slaID;

// Look up all active Catalogue Tasks where the u_task_sla field is blank.
var sctask = new GlideRecord('sc_task');
sctask.addActiveQuery();
sctask.addQuery('task_sla', null);
sctask.query();
while (sctask.next()) {
	
	// For each Catalogue Task set it's number are a variable.
	taskNum = sctask.number;
	
	// Look up the task_sla table and check is there is a matching SLA Task for the Catalogue Task.
	var sla = new GlideRecord('task_sla');
	sla.addQuery('task.number', taskNum);
	sla.query();
	if (sla.next()) {
		
		// If a matching record is found set it's sys_id as a variable.
		slaID = sla.sys_id;
		
	}
	
	// Set and update the u_task_sla field on the Catalogue Task with the task_sla record.
	sctask.u_task_sla = slaID;
	sctask.update();
	
}

 

Step 3: Dot walk to add the Business Elapsed Percent and Business Time Left columns to the list view.

  • From the Catalogue Task list go to Configure > List layout 
  • Scroll down and highlight Task SLA and click the expand icon
  • Add the Business Elapsed Percent and Business Time Left to the selected slush bucket and hit save.

 

Hope this helps.

 

Cheers

Daniel

Sabiii
Tera Contributor

Hi, I have 3 SLA's for one case. It is possible to rewrite your code to only show one of these SLA's on the case list?

Is this possible to apply to the case table?