- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 03:32 AM
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
- Creating a new SLA Definition
- 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!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 11:51 PM
Andy,
I tried it myself and it works for work notes field!!!
Please verify.
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:
RESULT:
Please Mark it correct and helpful if it was 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2018 11:51 PM
Andy,
I tried it myself and it works for work notes field!!!
Please verify.
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:
RESULT:
Please Mark it correct and helpful if it was 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 06:31 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 03:47 AM
Thanks Vidyasagar! Thanks for taking time for all the screenshots, very helpful!