Report on Incident Response Time [creation to first work_notes update], how?

andy_dufresne
Tera Expert

Greetings All,

I'm tasked to capture time the response time between the Incident Create time to first worknotes created on that incident.

I'm thinking of doing this way, but

  1. Creating a new SLA Definition
  2. Under 'Start condition'I cannot find either comments/work_notes. So how do I capture this?

Am I thinking wrong? Is there a better approach for this?

Thanks a million!!

 

1 ACCEPTED SOLUTION

Sagar Patro
Kilo Guru

Andy,

I tried it myself and it works for work notes field!!!

Please verify.

find_real_file.png

Script:

// variables available
// current: GlideRecord -  target incident
// definition: GlideRecord -  (this row)
var n = current.sys_mod_count;
gs.log("inside this 1");
if (n > 0 && current.work_notes.getJournalEntry(1) != ""){
	
	gs.log("inside this 2");
	  createMetric();
}
	

function createMetric() {
  var mi = new MetricInstance(definition, current);
  if (mi.metricExists()) 
    return; 

  var gr = mi.getNewRecord();
  gr.start = current.sys_created_on;
  gr.end = current.sys_updated_on;
  gr.value = current.work_notes.getJournalEntry(1);
  gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
  gr.calculation_complete = true;
  gr.insert();
}

TEST:

find_real_file.png

 

RESULT:

 

find_real_file.png

 

Please Mark it correct and helpful if it was 🙂

 

 

View solution in original post

7 REPLIES 7

Sagar Patro
Kilo Guru

Andy,

I tried it myself and it works for work notes field!!!

Please verify.

find_real_file.png

Script:

// variables available
// current: GlideRecord -  target incident
// definition: GlideRecord -  (this row)
var n = current.sys_mod_count;
gs.log("inside this 1");
if (n > 0 && current.work_notes.getJournalEntry(1) != ""){
	
	gs.log("inside this 2");
	  createMetric();
}
	

function createMetric() {
  var mi = new MetricInstance(definition, current);
  if (mi.metricExists()) 
    return; 

  var gr = mi.getNewRecord();
  gr.start = current.sys_created_on;
  gr.end = current.sys_updated_on;
  gr.value = current.work_notes.getJournalEntry(1);
  gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
  gr.calculation_complete = true;
  gr.insert();
}

TEST:

find_real_file.png

 

RESULT:

 

find_real_file.png

 

Please Mark it correct and helpful if it was 🙂

 

 

Hi Sagar,

I have a similar requirement as this report. I need to capture the first additional comments in the incident report. I have modified the script that you shared but it is not working. Any idea? 

andy_dufresne
Tera Expert

Thanks Vidyasagar! Thanks for taking time for all the screenshots, very helpful!