How to Value Empty value in metric definition

sivasankar Yash
Tera Contributor

Scenario: If case is opened assigned to  is empty In that case I need to capture that empty duration in metric definition under metric

1 REPLY 1

Anand Kumar P
Giga Patron
Giga Patron

Hi @sivasankar Yash ,

 

To track the time until the Assigned to field is populated, navigate to Metrics > Definitions, create a new metric, and select Script Calculation. Use a script that checks if Assigned to is not empty, then calculates and records the duration between the case creation and update.

 

  1. Navigate to Metrics Definitions:
  2. Go to Metrics > Definitions and click on Create New.
  3. Set Up the Metric Definition:
  • Name: Provide a name for the metric.
  • Table: Select Case
  • Field: Choose Assigned to.
  • Type: Select Script Calculation.

 

Script: 

 

var AssignedTo = current.assigned_to;
if (AssignedTo != '')
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.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand