How to pause or stop time in field time worked

dianemiro
Kilo Sage

Hi,

I have a client script to set time worked field as read-only if the ticket is created more than a month ago. I already set it to read-only and make hidden the pause/play button but as we have a setting to Start timers automatically and mine is set to true, the time worked still ticking. May I know if there's a way to pause or stop this time? Many thanks.

1 ACCEPTED SOLUTION

dianemiro
Kilo Sage

Hi All,



I see there is now way to Pause the automatic timers so what I did is I created a business rule and set my conditions as follows:



find_real_file.png


View solution in original post

9 REPLIES 9

lSurya 24
Giga Guru

Hello Miro,



The below might help your cause:



https://www.servicenowguru.com/scripting/client-scripts-scripting/pausetoggle-time-worked-field/



Thanks,


Surya Amara



PS: Hit like, Helpful or Correct depending on the impact of the response


Hi Surya,



Many thanks, we already have this script. What I want to do now is to pause it even if my timers start automatically. Do you know how?


Hello Diane,



I don't think the nature of the field-type allows to pause the field itself.



You can however set the value of this property: "glide.ui.timer.started" = false; which will allow not to run the timer automatically.



Thanks,


Surya Amara



PS: Hit like, Helpful or Correct depending on the impact of the response


Hi,



The code "glide.ui.timer.started" = false; have a lot of errors in warning, can you show how will I add it on this code?



function onLoad() {


  //Type appropriate comment here, and begin script below


  var user = new GlideRecord('sys_user');


  user.get(g_user.userID);


  if('sys_created_on', '>', 'javascript:gs.monthsAgo(1)'){


  g_form.setReadOnly('time_worked', true);


  jQuery('#link\\.incident\\.time_worked').parent().hide();



  }


}