How to Value Empty value in metric definition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2024 10:26 PM
Scenario: If case is opened assigned to is empty In that case I need to capture that empty duration in metric definition under metric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 12:26 AM - edited 12-22-2024 12:27 AM
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.
- Navigate to Metrics Definitions:
- Go to Metrics > Definitions and click on Create New.
- 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