updating metric instace when field value changes

brostoff17
Tera Contributor

I have a metric definition to capture the duration from an actual start to actual finish field.   However, when these field are updated after the initial metric is captured, the metric does not update as well.   Is there a way I can get the metric to update when someone updates one of these fields so it will recalculate the duration?

createMetric();

function createMetric() {

  var mi = new MetricInstance(definition, current);

  if (mi.metricExists())

      return;

  var gr = mi.getNewRecord();

  gr.start = current.u_actual_start;

  gr.end = current.u_actual_finish;

  gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());

  gr.calculation_complete = true;

  gr.insert();

}

Capture.PNG

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

Hi Josh,



You need to select field on your table which will be user to trigger metric instance calculations.


Please refer below metric definition which calculates metric instance when active flag on incident table turns of false.


find_real_file.png



Regards,


Sachin


JHufford
Mega Guru

I'm having a problem where the field value duration is not capturing the "end" date and therefore is not calculating. How can this be fixed? 

JHufford_0-1704913250234.png