SaveDraft is not working for me
My requirement is when I click the Save button the user input will save into a draft and as in Form IO under "Use" behavior user will be redirected to a page to view the draft mode. Again on clicking the Edit button there, the user can start editing the rest of the fields.
I tried to integrate following the documentation, but not working for me:
Formio.createForm(document.querySelector("#<%=tools.getParamValue("formIOID") %>"), <%= jsonText %>, {saveDraft: true}).then(function(form){
getNextPageResponse(form);
saveSubmit(form);
});
I am also instantiating the method to window.location inside thesubmitevent, still no luck.
Any help is highly appreciated.
Try setting the submission.state property to "draft" before submit.
form.submission.state = 'draft';
Thanks, @edwinanciani for your comment. I'll look into it.
Hi,
I'm also having no luck with getting this feature working. We host an on premise enterprise environment (Portal version Application: 7.0.40, Renderer: 4.11.3)
I follow the documentation here: https://formio.github.io/formio.js/app/examples/savedraft.html
To clarify: I'm trying to implement this for "Anonymous" user
And created this form: https://codepen.io/duongph/pen/VwYZvaV
I verified the Formio.setUser function worked:

When the "Save as draft" button is clicked, the draft submission is successfully submitted, however there seems to be several issues:
- Spin icon does not stop on the Save as Draft button
- The "owner" is not set on the submission
- When returning to the form (refresh or open a new browser tab) the data is not restored. If I check console the error shows "Cannot restore draft because there is no formio instance."

I modified the script and it worked for me.
Form Io has a method if(component.component.key ==="") with which we can trigger any component. Through it, I found the Save button component and initiated my custom function to save the form data and it's working perfectly for me.
@phucduong86 have you actually solved this issue? I have the same behavior.
hi @DonAmit197 can you send a piece of code which has if(component.component.key ==="") i want to know the way of using?
You can only use what you are after in form.everyComponent method where component is a parameter.
@phucduong86 have you actually solved this issue? I have the same behavior.
Hi, unfortunately no we are shelving this work item for now.
@DonAmit197 it appears that you have resolved this behavior, if not please let us know. @phucduong86 Save as Draft will not work with Anonymous users, please find more details at: https://help.form.io/faq/tutorials-and-workflows/save-as-draft