Nintex Forms : Implementing auto save functionality to save the form automatically after a time interval
By default, the form digest settings have a value of 30 minutes for all the forms in SharePoint. This
setting also affects the Nintex forms. Due to this, if there is a long Nintex form having many controls and
is open for more than 30 minutes, it does not save any values to the list upon submission. In order to
correct this, we can add some JavaScript to force the form to auto save after 28 minutes.
To create this solution, we need to add an extra Save button on the form and set a css class on this
button named ‘AutoSaveButton’ to find this button in JavaScript.
Then, following JavaScript needs to be added in the custom JavaScript section of the form which clicks
the hidden ‘AutoSave’ button using jquery after 28 minutes.
var mins = 28;
//Set the number of minutes you need
var secs = mins * 60;
var currentSeconds = 0;
var currentMinutes = 0;
NWF$(document).ready(function(){
HideAutoSaveControls();
SetAutoFormSaveTimer();
});
function HideAutoSaveControls()
{
if(Is New Mode || Is Edit Mode)
{
NWF$('.AutoSaveButton').css('display','none');
}
}
function SetAutoFormSaveTimer()
{
if(Is New Mode || Is Edit Mode)
{
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
{
isFormSubmittedAlready=NWF$('.saveButton').is(':disabled');
if(!isFormSubmittedAlready)
{
NWF$('.AutoSaveButton').click();
alert('Form saved automatically as it has not been saved for last '+mins+' minutes');
}
}
}
setting also affects the Nintex forms. Due to this, if there is a long Nintex form having many controls and
is open for more than 30 minutes, it does not save any values to the list upon submission. In order to
correct this, we can add some JavaScript to force the form to auto save after 28 minutes.
To create this solution, we need to add an extra Save button on the form and set a css class on this
button named ‘AutoSaveButton’ to find this button in JavaScript.
Then, following JavaScript needs to be added in the custom JavaScript section of the form which clicks
the hidden ‘AutoSave’ button using jquery after 28 minutes.
var mins = 28;
//Set the number of minutes you need
var secs = mins * 60;
var currentSeconds = 0;
var currentMinutes = 0;
NWF$(document).ready(function(){
HideAutoSaveControls();
SetAutoFormSaveTimer();
});
function HideAutoSaveControls()
{
if(Is New Mode || Is Edit Mode)
{
NWF$('.AutoSaveButton').css('display','none');
}
}
function SetAutoFormSaveTimer()
{
if(Is New Mode || Is Edit Mode)
{
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
{
isFormSubmittedAlready=NWF$('.saveButton').is(':disabled');
if(!isFormSubmittedAlready)
{
NWF$('.AutoSaveButton').click();
alert('Form saved automatically as it has not been saved for last '+mins+' minutes');
}
}
}
Comments
Post a Comment