Can you add a timer to a non task form?

ryan_cox
Giga Contributor

I have to add a timer like on Incident but to the New Call table. Is there a way to do that? I do not see it as a valid field type.

6 REPLIES 6

randrews
Tera Guru

you can create a workflow off of the incident table if you want... and throw a timer in that.. i do it to fire off emails to VP's if a pri 1 remains unassigned for to long.


d_cammack
Tera Guru

Hello Ryan,


Just to clarify... do you mean a field like Time Worked field that counts how long a person has a ticket open?   If the New Call table is extended from the Task table, this should be available to use on the New Call table.



Thanks,
David


paul_mcnamara
Giga Expert

The Timer field is only available on tables that extend from the task table.



If you really require this functionality it can be done but it would not not be recommended.



*DISCLAIMER I have not fully tested this solution so use at your own risk!



1) Remove the reference qualifier from the Type field on sys dictionary form.


2) Edit the Dictionary of the New Call Table and Create a new field of type timer


3) Put the reference qualifier back


4) Go to the task_time_worked.list and add a new Reference Column that references the Call[new_call] table


5) Find the BR - Task Time Worked.   Insert and Stay (do not modify original)


6) Update the code in the BR to the following.   Please not comments.


/* Updated the all occurrences of time_worked with u_time_worked (your field name) including the condition


*/


createTimeWorked();




function createTimeWorked() {


      //updated task, calc difference in timer


      if (current.operation() == 'update') {


              var end = current.u_time_worked.dateNumericValue();


              var start = previous.u_time_worked.dateNumericValue();


              var diff = end - start;


      }


      else {


              var diff = current.u_time_worked.dateNumericValue();


      }


      if (diff == 0)


              return;


     


      var tw = new GlideRecord('task_time_worked');


      tw.user = gs.userID();


      tw.u_new_call = current.sys_id;   // Your new Reference Field


      tw.time_worked.setDateNumericValue(diff);




      tw.insert();


}


7) Test Test Test


Perfect solution