Sharepoint SIG

Thoughts and ideas from your SharePoint support team

Nintex Forms – 30 minute timeout

| 0 comments

Some people on campus have run into a problem that affects Nintex Forms.  Default SharePoint forms are not affected by this problem.  The symptom of the problem is that, when the Save button is clicked, instead of going back to SharePoint the form reappears as a blank form and the contents of the form has not been saved.  The cause of this is a 30 minute timeout.  The timeout is a SharePoint setting that affects the entire server.

Ken Glover wrote a short JavaScript function that implements a workaround to this problem.  Despite the command in the code, it doesn’t actually submit the contents of the form, but it does keep the session alive so the form doesn’t time out and the contents aren’t lost if the form is open for more than 30 minutes.  This function can be added to any form that people may keep open for more than 30 minutes.

To add the function to the form, do EITHER:

  • Open Form Designer
  • Click on the Nintex Forms tab
  • Click on Settings icon
  • Expand the Custom JavaScript section
  • Copy the code below into the Custom JavaScript box

OR

  • Copy the code into a text editor such as NotePad
  • Create a file with a .js extension (e.g. FormTimer.js)
  • Upload the file to the Site Assets library in your site
  • Open Form Designer
  • Click on the Nintex Forms tab
  • Click on Settings icon
  • Expand the Advanced section
  • Copy the URL to the file in the Site Assets library into the Custom JavaScript Includes section
var mins = 28;  //Set the number of minutes you need
var secs = mins * 60;
var currentSeconds = 0;
var currentMinutes = 0;
setTimeout('Decrement()',1000);

function Decrement() {
    currentMinutes = Math.floor(secs / 60);
    currentSeconds = secs % 60;
    if(currentSeconds <= 9) {
        currentSeconds = "0" + currentSeconds;
    }
    secs--;
    //Set the element id you need the time put into
    document.getElementById("timerText").innerHTML = 
        currentMinutes + ":" + currentSeconds; 
    if(secs > -1) {
        setTimeout('Decrement()',1000);
    else {
        document.forms[0].submit();
    }
}

If you want the timer countdown to appear on the form:

  • Add a Rich Text control into the form where you want the timer to appear
  • Double click the Rich Text contr0l to open it
  • Click in the editor window, wait until the editing ribbon appears
  • Click the “Edit Source” icon in the ribbon
  • Paste in the following HTML string

This form will autorefresh in <b> <span id="timerText"></span></b> minutes

Adjust the text in the Rich Text control to say what you want.  Publish the form and exit.  When you create or edit an item in the list, you will see the timer pop up in the form and the countdown will start.  If the form is open for more than 28 minutes, the timer will restart.

Leave a Reply