The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Business elapsed time

Balakrishna_ABK
Tera Guru

I have requirement:

To track time taken from open to resolved states of tickets excluding on hold reasons and non business hours.

I have two options:

1. To use 'business elapsed time' of task_sla but not sure whether 'business elapsed time' run even sla is breached and in other conditions.

2. To modify OOB metric on incident table "Create to Resolve Duration" which shows entire duration but it will not take onhold reasons and non business hours into consideration.

 

Please suggest better solution.

 

6 REPLIES 6

Hi @Danish Bhairag2 , thanks for quick reply, I have modified the code below but its not working, please suggest if any changes

// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)

// Get the business hours schedule
var schedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae','America/Los_Angeles');
schedule.load();

var s = current.incident_state;
if (s >= 6)
  createMetric();

function createMetric() {
  // Check if the incident state is not 3
  if (current.incident_state != 3) {
    var mi = new MetricInstance(definition, current);
    if (mi.metricExists())
      return;

    var gr = mi.getNewRecord();

    // Adjust start and end times to business hours
    var start = schedule.getStartDateTime(current.sys_created_on);
    var end = schedule.getStartDateTime(current.sys_updated_on);

    gr.start = start;
    gr.end = end;

    // Calculate duration only for business hours
    gr.duration = gs.dateDiff(start, end);

    gr.calculation_complete = true;
    gr.insert();
  }
}

AndersBGS
Tera Patron
Tera Patron

Hi @Balakrishna_ABK ,

 

Don't modify the OOTB metric on incident table "create to resolved duration". This is exactly what SLA which comes OOTB is for. A SLA business duration will run within the defined schedule under the defined condition that you set, together with it can be paused under on hold reasons. 

 

Furthermore to answer your query, even though an incident breach SLA, the business duration will keep running till the stop condition is met. 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/