How to setup 'Duration' field on sc_task?

Jana_S
Tera Expert

Hi All,

 

I am having issue trying to make the duration field on sc_task work, I understand that duration fields are not calculated on task table by default but was wondering if I could make it work by using the BR from the incident table and replicating it on either the task or sc_task table? Is this possible when the task state is set to closed_complete, if so please provide the customised script.

 

Thank you in advance,

Jana

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @Jana_S 

 

You can use BR with script like below that will trigger when state changes to closed complete

  var startDateTime = current.sys_created_on.getGlideObject();  //use your start date/time field

  var endDateTime = new GlideDateTime();
 
  current.duration = gs.dateDiff(startDateTime.getDisplayValueInternal(),endDateTime.getDisplayValueInternal(),false);  
 

 

View solution in original post

1 REPLY 1

Manmohan K
Tera Sage

Hi @Jana_S 

 

You can use BR with script like below that will trigger when state changes to closed complete

  var startDateTime = current.sys_created_on.getGlideObject();  //use your start date/time field

  var endDateTime = new GlideDateTime();
 
  current.duration = gs.dateDiff(startDateTime.getDisplayValueInternal(),endDateTime.getDisplayValueInternal(),false);