Write a script to calculate the time taken from new to in progress state of incident and display

Sharmila Krishn
Tera Contributor

Write a script to calculate the time taken from new to in progress state of incident and display on form field.

5 REPLIES 5

Madhankumar T3
Tera Expert
you try this business rule
 
(function executeRule(current, previous /*null when async*/ ) {
    // Check if the incident has transitioned from 'New' to 'In Progress'
    var createdTime = current.sys_created_on;
    //gs.log("query:" + createdTime);
    var updatedTime = current.sys_updated_on;
    //gs.log("query:" + updatedTime);
    var timeDifference = gs.dateDiff(createdTime, updatedTime);
    //gs.log("query:"+ timeDifference);
    //var day = timeDifference.getDay();
    //var day =parseInt(timeDifference);
    gs.addInfoMessage("the time taken from 'new' to 'in progress' state of incident and display"+ timeDifference);
})(current, previous);