How do I "Stop" Time Worked when task is closed?

Not applicable

I'm trying to pause the timer when the task is closed, but an itil user is going back to key additional information (SLMs love doing this).

This is starting to skew our time tracking. Just wondering if somebody knows how to stop the timer using a client script? (Simulate an onClick event?)

I've found "Toggle Timer Field by Field Name":

http://wiki.service-now.com/index.php?title=Toggle_Timer_Field_by_Field_Name

I know I can also update the business rule

Incident Time Worked
to drop the update based on incident state, but I'm looking for a solution that is visible to the user.
11 REPLIES 11

Hi Mark,



I need to pause the timer on task form when it is closed complete.i wrote below script but it is not working.Please could you let me know what has gone wrong.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  //   if (isLoading || newValue === '') {


  return;


  // }


  if (newValue === 'Closed Complete'){


  if(g_form.getElement('time_worked')){


  toggleTimer('time_worked');


  }


  }



}


  function toggleTimer(fieldName) {


  var timeObjectName = fieldName;


              var timeObjectHidden = gel(timeObjectName);  


  var timeObjectParent;


              var timeObjectFields;


    if (timeObjectHidden.type == "hidden") {


              timeObjectParent = timeObjectHidden.parentNode;


              timeObjectFields = timeObjectParent.getElementsByTagName("input");



      var timerTestString = "paused";


      var timerImg;



      //loop through input objects looking for the pause timer object


      for(var elIt=0; elIt < timeObjectFields.length; elIt++) {


          if (timeObjectFields[elIt].id.match(timerTestString)) {


              if(timeObjectFields[elIt].value == "false") {


                  timeObjectFields[elIt].value = "true";


                  timerImg = timeObjectParent.getElementsByTagName("img")[0];


                  timerImg.src = "images/timer_start.gifx";


              } else if (timeObjectFields[elIt].value == "true") {


                  timeObjectFields[elIt].value = "false";


                  timerImg = timeObjectParent.getElementsByTagName("img")[0];


                  timerImg.src = "images/timer_stop.gifx";


              }


          }


      }


  }


}




Regards


Sheetal


JHufford
Mega Guru

I have a table that extends Task and cannot get this to work. Is there any magic involved?