setTimeout() doesn't call function after specified time in Nintex forms for SP2013

  • 19 June 2019
  • 2 replies
  • 11 views

I am trying to display a message on form submission after user saves an SP2013 list item.



Here's the custom JS in Form settings:



function MyButtonOnClientClick(){ 



setTimeout(function() { 



   SP.UI.ModalDialog.showWaitScreenWithNoClose('Working on it', 'Please wait, the form is being submitted...');   



}, 10000); 



}


 



Added the following to OnClientClick action of Submit button:



javascript:MyButtonOnClientClick()



The wait screen doesn't get displayed and item gets saved to SharePoint list.



Most previous posts with similar issue seem to do with the function call inside setTimeout function but that doesn't seem to be the problem here.



Any suggestions please?


2 replies

Haven't done this for a while but are you sure that "javascript:MyButtonOnClientClick()" is the correct value at this point? As far as i remember you only need to enter the name of the js function you want to execute on client click which would be "MyButtonOnClientClick()".



 



Can you add some console.log() inside your function just to see if it is executed at all?

setTimeout() and setInterval() functions allow you to execute a piece of JavaScript code/function at a certain point in the future. setInterval repeats the call, setTimeout only runs it once.



 



setTimeout(expression, timeout); runs the code/function once after the timeout. It is a time based code execution method that will execute script only one time when the interval is reached, and not repeat again unless you gear it to loop the script by nesting the setTimeout object inside of the function it calls to run. If geared to loop, it will keep firing at the interval unless you call clearTimeout(). If you want something to happen one time after some seconds Then use setTimeout... because it only executes one time when the interval is reached.



 



setTimeout(function() {
console.log('Wait 3 seconds and I appear just once');
}, 3000);



 



setInterval(expression, timeout); runs the code/function repeatedly, with the length of the timeout between each repeat. It is a time interval based code execution method that has the native ability to repeatedly run specified script when the interval is reached. It should not be nested into its callback function by the script author to make it loop, since it loops by default. It will keep firing at the interval unless you call clearInterval(). If you want to loop code for animations or clocks Then use setInterval.



 



setInterval(function() {
console.log('Every 3 seconds I appear on your console');
}, 3000)



 

Reply