Calculate resolution time

SM123
Tera Expert

Hello All,

I have created a new field called "resolution time" it should show duration on following bases until the ticket gets resolved. Monday to Friday (from 9am to 6pm). Saturdays, Sunday should be excluded. should also not count the time when the ticket is in state Pending, Pending Caller, Pending Effective date.This is in order to check how much time did assignee took to resolve a ticket

Please provide some ideas how to achieve it. I have BR in mind but not sure how to calculate all these scenarios.

Your help will be appreciated. 

4 REPLIES 4

AshishKM
Kilo Patron
Kilo Patron

Hi @SM123 , 

 

I believe, you must have some SAL configured on that table record, and SLA is already calculating the actula and business duration.

 

You can copy the business elapsed time to resolution time field via BR when record is set to resolved.

 

AshishKM_0-1735576323452.png

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM ,

Our SLA only calculates 24*5 mon-fri (all day) but i need 9am-6pm. our sla will only pause for pending caller state.

Ok got it, then you need new schedule definitaion, as suggested by @Runjay Patel and calculate the time.

Or if possible, create new SLA for this requirement.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Runjay Patel
Giga Sage

Hi @SM123 ,

 

You need to create one schedule in which you need to exclude the weekends and set the time of business days and use sys ID of schedule in below code.

 

var dc = new DurationCalculator();
dc.setSchedule('<sys ID of schedule>'); 
var diff = dc.calcScheduleDuration(current.sys_created_on, current.resolved_at) ;

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------