Is there any option on timer field to write onChange client script?

swathigangadhar
Tera Expert

Is there any option on timer field to write onChange client script? If some one changes it manually i need to alert message. How to achieve it?

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Swathi,



Can you explain your requirement in detail?


Do you want to add timer i.e. you want to wait for few seconds before performing any other activity?



you can wait for particular number of seconds using this line of code



setTimeout(callAfterTimer, 5000); // this will call the function after a period of 5000 milliseconds


you can then write your code in the function callAfterTimer



Mark my reply as Correct and also hit Like and Helpful if you find my response worthy.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Nana5
Mega Guru

HI Swathi,


You can try below example.


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


  if (newValue == oldValue){


    return;


  }  



  window.setTimeout(fun2,5000);


}



function fun2(){


  // do your stuff here


  alert('I waited 5 seconds.');


  var caller = g_form.getReference('caller_id');


  g_form.setValue('location', caller.location);


}


I have a incident form in which am having a field called Timer (type is timer), Whenever person opens timer will start, and it is editable also, i want to alert message, when some one edit this timer field.



ie.,


onChange of Timer


{


alert('You editing timer');


}


I have a incident form in which am having a field called Timer (type is timer), Whenever person opens timer will start, and it is editable also, i want to alert message, when some one edit this timer field.



ie.,


onChange of Timer


{


alert('You editing timer');


}