The CreatorCon Call for Content is officially open! Get started here.

Help: Behaviour or limitations of endDuration() method for MetricInstance

Amith Makkuva
Tera Contributor

We are trying to achieve the timeline duration when a Demand (dmn_deman) is moved to submitted state (s ==2 )and end time will be based on the related story under a different table 'rm_story' and its state hits queued for dev (s == 52). 

 

the problem is the end duration never hits or records under the instance record. this is the script and need help with a solution as no forum is giving me solutions.

 

Metric Definition details and criteria :

table - dmn_demand

Field - State

 

Script:

var s = current.state;
var mi = new MetricInstance(definition, current);

if (!mi.metricExists()) {
if (s == 2) {
mi.startDuration();
}
}
 
var grStry = new GlideRecord('rm_story');
grStry.addQuery('demand', current.sys_id);
grStry.query();

while (grStry.next()) {
gs.log("Checking story: " + grStry.sys_id + " with state: " + grStry.state);
if (grStry.state == 52) {
if (mi.metricExists()) {
mi.endDuration();
}
break; // Exit loop after finding the first matching story
}
}
0 REPLIES 0