- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2016 09:07 AM
I want to create a metric on task_sla table. This table contains has_breached field. When ever that field is true, I want to capture the assignment group at that particular time when the SLA is breached.
I have created a metric on Task_sla table and struck up at the scripting part.
Any help is appreciated.
Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 05:12 AM
So your getting some data? Change the script to this:
if (current.has_breached == true) {
createMetric();
}
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.value = current.task.assignment_group;
gr.calculation_complete = true;
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 05:20 AM
In the earlier posts you have mentioned about the Business rule, What code should I keep there? I am clear with the metric code now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 05:47 AM
There is a business rule named metric events on the task table. Copy that BR and change the table to task_sla. No other changes to business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 08:12 PM
Michael,
I implemented the same you said. But the metric definition is not capturing the data or its not capturing the assignment group of incident when its SLA is breached.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 05:12 AM
So your getting some data? Change the script to this:
if (current.has_breached == true) {
createMetric();
}
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.value = current.task.assignment_group;
gr.calculation_complete = true;
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 01:39 AM
Hi Micheal.
Did it work?
I am trying the same thing on 'incident_alert' table. I have added the metrics events business, changed the table to 'Incident Alert' and now trying to work through my metric definition. I am not seeing any metric instance being initiated?
Thanks for your help.