- 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-29-2016 06:55 PM
I don't believe you need to change the event, just duplicate the business rule with the task_sla table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 07:10 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2016 07:35 PM
Change the type to Script and use the script from the earlier post:
if (current.active) {
if (current.has_breached.getDisplayValue() == 'true') {
createMetric();
}
}
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.field_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-29-2016 08:06 PM
Michael,
Thanks for your patience on this. One final clarification, The script you have posted would be in Business rule and the script David has posted will be in the metric right?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2016 05:03 AM
The script I posted would be a metric script, not a business rule.