need to hold screen for 3 secs when any option is getting changed on form

anshul_jain25
Kilo Guru

I want to hold screen for around 3 secs when i am changing a value of a variable on my form,

what will be the function that i can use in my on change client script.

1 ACCEPTED SOLUTION

Aakash Shah4
Tera Guru

For client side you can use setTimeOut()


Window setTimeout() Method


View solution in original post

9 REPLIES 9

Hi jain,



Please provide the more information your requirment. Any particular reason to hold the screen




Thanks


Chandu telu


I agree with Chandu... it's important that we understand the requirement here before trying to implement a solution. You have pointed us to what you believe is the solution, but we don't understand what the use case is. This is risky and can lead to performance issues.



http://xyproblem.info/


varads_kulkarni
Giga Expert

Hi Anshul,



You will have to use the combination of Script Include and synchronous GlideAjax. Follow the below steps to get it done.


1) Create a Client Callable Script include with a single function and gs.sleep(milliseconds) statement.


2) Use Synchronous Glide Ajax on a onChange Client Script to call the above Script Include.


3) Use getXMLWait() function.



Script Include Code


-------------------------------


var PauseScreen3Seconds = Class.create();


PauseScreen3Seconds.prototype = Object.extendsObject(AbstractAjaxProcessor, {




pauseScreen: function(){


gs.sleep(5000);


},


      type: 'PauseScreen3Seconds'


});


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



onChange Client Script


-------------------------------


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


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


          return;


    }




var ps = new GlideAjax('PauseScreen3Seconds');


ps.addParam('sysparm_name','pauseScreen');


ps.getXMLWait();


alert('I waited for 5 seconds');


    //Type appropriate comment here, and begin script below


   


}



For more details refer how to keep waiting the business rule for some time.



Thanks & Regards,


Varad S.Kulkarni


anshul_jain25
Kilo Guru

Thank you all i some how managed to do what i was looking for,


PriyaRanji
Tera Guru

Hello,

You can write the below line of code to wait for few seconds.

var setTimer='';

setTimer=setTimeout(setTimerDelay,2000);/*to set the timer for 2 sec*/

function setTimerDelay(){

alert('timer waits for 2 sec');

//your code 

}

 

Hope it will helps you!

Thanks,

Priyanka R