Age field on task table

snehalkhare
Kilo Guru

Hi All ,

I want to create a field which calculates age of the open tickets on the task table . I want it on Task table so that it can be used to calculate the age of all the tickets - incident , problem ,request etc.

How this can be done ? After creating this field it has to be used for reporting on task table , means all the open tickets -incident , problem ,request etc. ( ages ) can be represented in the report.

Thanks & Regards,

Snehal Khare

11 REPLIES 11

Hi Ujjawal


This scheduled job will calculate the age only when it is run right. But if we need to calculate the age always then is it possible?



Thanks ,


Snehal Khare


Hi Snehal,



Apart from this approach, you can use the calculated value.Create a duration field and go to advance view then set the calculated tab as below.



gs.dateDiff(current.sys_created_on.getDisplayValue(),gs.nowDateTime(),false);






Hope this helps.



Regards


Ujjawal


Arindam Ghosh
Mega Guru

Please follow the below steps to achieve this:



Step-1) Create a duration field on task table.


Step-2) Add that field to all task type form (like incident, problem, catalog task etc.).


Step-3) Create UI policies to display that field on form for specific status for each form.


Step-4) Create a onload Client script using GlideAjax to calculate the duration.



Thanks,


Arindam


Nithin12
Tera Expert

You can also write a Display business rule, But this will calculate the age when when the user opens the record.


I have created two bossiness rules one is Display(not in closed state) and other is before Update (state goes to closed).


So when ever user opens the record it will update the age which will be live data.


When ever the record is closed or resolved age will be calculated.


on dispaly


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



  calculateAge();


  function calculateAge(){


  var datedif = gs.dateDiff(current.opened_at.getDisplayValue(), gs.nowDateTime());


  current.u_age = datedif;


  current.update();


  //gs.addInfoMessage("Age"+ datedif);


  }



})(current, previous);


before update


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




  calculateAge();


  function calculateAge(){


  var datedif = gs.dateDiff(current.opened_at.getDisplayValue(), gs.nowDateTime());


  current.u_age = datedif;



  //gs.addInfoMessage("Age"+ datedif);


  }




})(current, previous);


Hi Nithin,


Is it possible that we use calculated field on task table for this purpose.?



Thanks,


Snehal Khare