We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Any advice on using duration field for closed problem tasks

JohnEJasinski
Tera Expert

Help - trying to use the Duration field on Closed Problem Tasks.   

Created to Closed, but nothing is showing in the Duration field.   

What am I missing?  

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

Hi @JohnEJasinski 

 

Duration is a field whcih is on the task table and here are a few details

 

https://www.servicenow.com/community/itsm-forum/how-to-calculate-duration-field-on-task-table/m-p/65...

https://www.servicenow.com/community/csm-forum/catalog-task-duration-business-rule/m-p/403227

https://www.servicenow.com/community/developer-forum/how-to-setup-duration-field-on-sc-task/m-p/2613...

 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Robert H
Mega Sage

Hello @JohnEJasinski ,

 

Using the Duration and especially the Business Duration fields is no longer recommended, as SLAs provide a better alternative that gives more control over the schedules and time zones involved in the calculation.

 

If you want to go ahead with using the duration fields you can create a Business Rule as shown below:

 

RobertH_0-1745650173277.png

 

Advanced Script:

(function executeRule(current, previous /*null when async*/ ) {

    current.business_duration = gs.calDateDiff(current.opened_at.getDisplayValue(), current.closed_at.getDisplayValue(), false);
	
    current.calendar_duration = gs.dateDiff(current.opened_at.getDisplayValue(), current.closed_at.getDisplayValue(), false);

})(current, previous);

 

Regards,

Robert