Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Incident First Response metric

Anupriya_11
Tera Contributor

Hi Team I have a requirement where incident is upgraded to P1/P2  'Incident First Response' metrics start date to updated as current time when the 'major incident state' field is updated proposed/accepted . If rejected  then  it should update  the Incident First Response START CONDITION override to the default (existing: CREATED TIME).

I have tried the below script  it is not working, can some one help me on this.

Requirements:

1. START CONDITION - the incident ticket MAJOR INCIDENT STATE is PROPOSED
2. STOP CONDITION - the incident ticket State is changed to or equal to IN PROGRESS, On-Hold, Resolved, Assigned
3. Assignment group is SD-GBL-CIMG
4. Assignee is not empty

5. Major Incident state is equal to ACCEPTED only

 

if (current.state == 2 || current.state == 3 || current.state == 6 || current.state == 8 ) // State = In Progress || On Hold || Resolved || Canceled
    createMetric();

function createMetric() {
    var mi = new MetricInstance(definition, current);
    if (mi.metricExists())
        return;

    var frMi = mi.getNewRecord();
     var MajorIncident = current.major_incident_state;
     if (MajorIncident == 1|| MajorIncident == 2) {
       
        frMi.start = current.sys_created_on;
     } else{
       
        frMi.start = current.sys_created_on;
     }

   // frMi.start = current.sys_created_on;
    frMi.end = current.sys_updated_on;
    frMi.duration = gs.dateDiff(frMi.start.getDisplayValue(), frMi.end.getDisplayValue());
    frMi.calculation_complete = true;
    frMi.insert();
}

 

 

Thanks.

2 REPLIES 2

Uncle Rob
Kilo Patron

Can you describe what you mean when you say "not working"?

Hello Rob,

 i have added the below condition to the existing code , where it has to update the 'Incident First Response Timestamp' metric  start  field to be updated with the  actual time , when major incident state = proposed and if rejected  it should follow the existing condition (incident creation)

 

Anupriya_11_0-1734419091886.png

but this is not working as it  is still taking the incident creation date.

 
Anupriya_11_1-1734419463269.png

 

Thanks