# Form Designer: Automatic saving of the current form content after configurable time delay

**URL:** <https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278>\
**Category:** Form Designer\
**Created:** [December 10, 2014, 11:20pm UTC](https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278 "2014-12-10T23:20:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [December 10, 2014, 11:20pm UTC](https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278/1 "2014-12-10T23:20:37Z")

</div>

**Solution**

You have to install a JavaScript library to auto submit the form after a specified time delay.

- Reference: [http://www.webappers.com/2013/10/31/ifvisible-js-check-if-user-is-idle-or-active-on-the-page](http://www.webappers.com/2013/10/31/ifvisible-js-check-if-user-is-idle-or-active-on-the-page)

- Demo: [http://serkanyersen.github.io/ifvisible.js/demo.html](http://serkanyersen.github.io/ifvisible.js/demo.html)

The JavaScript library must be installed in the **\wfgen\wfapps\webforms\js** folder.

On the **Web References** tab in the **Form configuration** panel:

1. Check **Include jQuery API and jQuery UI libraries**.

2. In the textarea, insert the following JavaScript code with an idle duration of your choice:  

```auto
<script src="/wfgen/wfapps/webforms/js/ifvisible.js"></script>

<script>
    $(document).ready(function(){
        // Code executed in Runtime only
        if (typeof $selectedObject === "undefined")
        {
            // Set the idle limit to 10 seconds
            ifvisible.setIdleDuration(10);
            
            // Confirm save as draft if no activities more than 10 seconds.
            ifvisible.idle(function(){
                var r = confirm("There are no activities for more than 10 seconds!\nSave this form as draft?");
                if (r == true) {
                    $('#saveAsDraftButton').click();
                }
            });
        }
    });
</script> 

```

---

<div class="post-metadata">

**Author:** ![schaubal](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@schaubal](https://discuss.workflowgen.com/u/schaubal)\
**Post date:** [June 6, 2017, 1:39pm UTC](https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278/2 "2017-06-06T13:39:51Z")

</div>

The javascript code is missing in the solution of this article under #2

---

<div class="post-metadata">

**Author:** ![pnicoll](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/pnicoll/32/454_2.png) [@pnicoll](https://discuss.workflowgen.com/u/pnicoll)\
**Post date:** [June 6, 2017, 1:58pm UTC](https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278/3 "2017-06-06T13:58:38Z")

</div>

Hi Supriya,

Thanks for letting us know. The code has been re-inserted.

Best wishes,

Peter Nicoll

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://discuss.workflowgen.com/u/james)\
**Post date:** [May 4, 2018, 8:44pm UTC](https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278/4 "2018-05-04T20:44:22Z")

</div>

I just tried this and it does work in regards to a time limit. What I also noticed is that if the browser has other tabs open, the confirm box appears even if the time limit is not reached (and it can block the user from going to another tab). Any ideas or is there another solution (jquery or .Net code) to save as draft if there is not activity in a certain time?

Thanks,

James

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://discuss.workflowgen.com/u/james)\
**Post date:** [May 7, 2018, 4:30pm UTC](https://discuss.workflowgen.com/t/form-designer-automatic-saving-of-the-current-form-content-after-configurable-time-delay/278/5 "2018-05-07T16:30:13Z")

</div>

Think I may have that problem solved. I checked the Github page and there is this code that can be included:

```
ifvisible.on("blur", function(){
	// example code here..
	animations.pause();
});

ifvisible.on("focus", function(){
	// resume all animations
	animations.resume();
});
```
