Skip Ribbon Commands
Skip to main content

Laura Rogers @WonderLaura

:

Quick Launch

Laura Rogers @WonderLaura > Posts > InfoPath “Save Draft” Form Functionality – A Better Way
Hi everyone,
My blog now has a new URL!
You can now find me at http://www.wonderlaura.com
January 01
InfoPath “Save Draft” Form Functionality – A Better Way

There are a couple of buttons in InfoPath forms by default called “Save” and “Save As”.  I never ever (ever) like to use these, and immediately disable them.  I don’t like these buttons because it gives the end users the freedom to save the form with any filename at all, which can make a big mess of a form library.

This solution can be done in any version of SharePoint or SharePoint Online with Office 365.

So when I tell people that I always disable these buttons, people’s response is “Wait, but what if we need to give users the ability to save a draft of the form before they submit it?”  My answer is to still use the submit functionality only, and put buttons on the form for “Save” and “Submit”.

The tricky part of this solution, is the fact that a form will inevitably have a few required fields, but they’re not supposed to be required if it’s only a draft.  In this post I’ll show you how to accomplish this.  When users fill out a form, they will have a “save draft” button and a “submit” button, and users will not get an error when a draft is saved and required fields are not filled out.

In this example, I’m going to use a super simple form, with just a few fields.  There are four text fields, called FirstName, LastName, FormName, and FormStatus.

  1. For the FormName, the default value is translate(now(), ":-T", "")
    Be sure to uncheck the box “Refresh value when formula is recalculated”. This is the typical method I use for InfoPath file names.  Each filename will be unique, and it won’t be dependent on any particular fields being filled out.
    Oreilly-15
  2. Go ahead and publish this form to SharePoint.  I usually do this before creating the data connection for submitting. 
    (Note for beginners: For a full tutorial, screenshots and details about publishing and submitting forms, you can read chapter 6 in my book)
  3. In the browser, go to the form library you created when you published the form to SharePoint.  In the address bar, copy the URL to the clipboard.
  4. In the Data tab in your form, click To SharePoint Library.
  5. In the Document Library box, paste the URL to your new form library, the one you copied at step 3.  Remove the /Forms/AllItems.  For the file name, use the function button to select the FormName field in your form.  Check the box to allow overwrite if file exists.
    Oreilly-16
  6. Click Next.  Click Finish.
  7. This form is very simple, and has first name and last name text boxes.  Place two new buttons at the bottom of the form.
    Oreilly-18
  8. Select the SECOND button, and click the Properties tab in the ribbon.  In the Action drop-down, choose Submit.
    Oreilly-19
  9. Click the Submit Actions button.  Select Perform custom action using rules.  Click OK.
  10. In the Rules pane on the right, click the Add button, and choose Set a Field’s Value.
  11. For the field, select FormStatus, and for the value, just type the word Submitted.  Click OK.
    Oreilly-20
  12. Move this rule up above the “Submit” rule that was already there.
    Oreilly-21
  13. Click to select the first of the two buttons on the form, the one that still says “Button”.  If you don’t already see the Rules pane on the right, go to the Home tab, and click Manage Rules.
    Oreilly-22
  14. Create a new Action rule that will have 3 actions:  Set a field’s value, Submit, then Close.  Note that if you’re not sure how to set a field’s value, refer back to step 11.
    Oreilly-23
  15. With the button still selected, click the Properties tab in the ribbon.  For the Label, type Save as Draft.
  16. Just so that you can see the value of the form status, go ahead and drag the form status field onto the form.  Right click the field, choose Change Control, and choose Calculated Value.  This is a quick way of putting a read only field on the form.
  17. Open the properties of the FormStatus field, and set the default value as New.
  18. On the Data tab, click the Form Load button.  Create a new Action rule.  Name this rule Draft
  19. Click the blue text under the word Condition.  The condition is Form Status is equal to Draft.  Click OK.
    Oreilly-29
  20. Click the Add button, and create an action to set a field’s value.  Set the Form Status value to New.
  21. Now it’s time for the meat of how this solution works.  Click to select the First Name text box.  This is where we create a rule so that this field is not required if the form is in draft state.  In the Rules pane, click to create a new Validation rule.  You can call it “required”.
  22. Create the following as the conditions:
    Oreilly-30
  23. Type some text in the screen tip box:
    Oreilly-38
  24. Click the Copy icon at the top of the Rules pane (it’s the first of the 4 little icons at the top).
  25. In the form, click to select the Last Name text box on the form.  In the rules pane, click the Paste icon.  Notice that the rule was smart enough to alter itself to the new field’s name.
  26. Now it’s time to get rid of the Save and Save As buttons.  Click File, click Form Options, and uncheck the Save and the Save As options.  Click OK.
  27. One more thing.  You may want the “Save as Draft” button to go away after the item has been “submitted”, so a rule can be created for this.  Click to select the Save as Draft button.  In the Rules pane, click the New button, and choose Formatting (to create a formatting rule).  The condition needs to be FormStatus is not equal to Draft and FormStatus is not equal to New.  Check the box for Hide this control.  You can call this rule “hidden.
    Oreilly-40
  28. Click the Quick Publish button at the top.

Now go over to SharePoint, to your new form library.  Click to fill out a new form.  Notice that even if you do not fill out the required fields (the ones with red asterisks), you can still click to save the form as a draft.  If you try to Submit the form, though, the required fields must be filled out.  You also may want to go through the publishing wizard again, if you’d like to add the form status as a column in the SharePoint library.

A new form will look like this:

Oreilly-42

Comments

Step 14

Hi Laura,

Thank you very much for taking the time to put these instructions together.

I am having difficulty with step 14. I am attempting to add separate form submit options to my "save as draft" button, but the rule manager is showing all of my rules from my "submit" button.

I cannot add unique rules to each button. Do you know why this might be?

Thanks
Isaiah
 on 1/19/2012 10:23 AM

Isaiah

Hi Laura,

Isaiah here - I think my issue was that I had not published the form with both buttons.

After I published I was able to add custom action rules to my "save as draft" button.

Shame on me for not following directions ;)

Thanks again!
 on 1/19/2012 10:38 AM

Kevin

Laura,
Do you know of a way to have the draft version deleted from the draft library after it has been submitted to the main library. This would have to be a no code solution.
Thanks
 on 1/20/2012 12:40 PM

Laura

Hi Kevin,
There is no separate 'version' in this solution.  When they submit final, it overwrites the draft version.  I guess if you have versioning turned on in the form library, then the versions would be there, though.  So if you're getting rid of those versions, you could create a workflow that says:
IF FormStatus is equal to Submitted, the delete all previous versions.
Laura RogersNo presence information on 2/1/2012 10:49 AM

Alex

Hay Laura,

couldn't you just work with two Content Types, one for "drafts" with fields set to "optional" and another one, where those fields are "required"? Is there a way to set the used Content Type before saving in InfoPath? I know there is in SharePoint Designer, when creating a new List Item.

Best regards from Germany,
Alex

PS: Just curious: why don't you use a default value for "Today's Date"?
 on 2/8/2012 10:22 AM

Laura

Hi Alex,
No, form libraries work differently than lists.  That would be another way to do it... with a SharePoint list, but it seems more complicated to me, and I'd really only do that if InfoPath wasn't in the picture.
Oh, and I didn't use a default value because then every time you submit the form, it would save it as the file name of the date right then.  I want this value to be static, so I only set it once.
Laura RogersNo presence information on 2/9/2012 10:28 PM

Guru

Hi Laura,
I have one requirement, want to achieve from OOTB only. no code,
User submits data to a list ( car list) i want to prepolulate the previous Car which they have submitted lastly, means need to pull the CarName from the latest submitted item by the user and pre-populate the same in the new form.
any help? how to retrieve the latest item submitted by a USER through OOTB?
 on 2/21/2012 1:13 AM

Laura

Guru,
You can do that. Create a receive data connection to the same library you're in.  Then, you can use the "username()" function to figure out who the currently logged in user is. Then, perform a query to the data connection to receive just the records created by the logged in user, sorted by ID descending.  I'll have to blog about this. ;-)
lauraNo presence information on 2/24/2012 11:06 AM

Hans

I have implemented your solution and I also hide the Save as Draft button after submitting the form.
I face one problem. When submitting the form without providing the required fields, I get a warning pop-up with the options continue and start over. When I choose continue, the Save as Draft button is hidden since the field FormStatus is set before the submit action. How to make that button visible when choosing continue?
One way could be to have a submit action then set the FormStatus field and then submit again, since FormStatus is a promoted field in my solution.
Do you think this makes sense?
 on 5/20/2012 6:19 AM

Laura

Hans,
Good point.  Here's a trick:
In your actions in the submit button, add a "submit" action FIRST in addition to the submit action and the close action that you use last.
lauraNo presence information on 6/13/2012 10:13 PM
​I have disabled any new comments on this, because my blog has moved to a new site.  Please go here: http://www.wonderlaura.com
RSS FeedFacebookYouTube
 

 Our Books for End Users