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.
- 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.
- 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)
- 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.
- In the Data tab in your form, click To SharePoint Library.
- 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.
- Click Next. Click Finish.
- This form is very simple, and has first name and last name text boxes. Place two new buttons at the bottom of the form.
- Select the SECOND button, and click the Properties tab in the ribbon. In the Action drop-down, choose Submit.
- Click the Submit Actions button. Select Perform custom action using rules. Click OK.
- In the Rules pane on the right, click the Add button, and choose Set a Field’s Value.
- For the field, select FormStatus, and for the value, just type the word Submitted. Click OK.
- Move this rule up above the “Submit” rule that was already there.
- 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.
- 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.
- With the button still selected, click the Properties tab in the ribbon. For the Label, type Save as Draft.
- 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.
- Open the properties of the FormStatus field, and set the default value as New.
- On the Data tab, click the Form Load button. Create a new Action rule. Name this rule Draft.
- Click the blue text under the word Condition. The condition is Form Status is equal to Draft. Click OK.
- Click the Add button, and create an action to set a field’s value. Set the Form Status value to New.
- 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”.
- Create the following as the conditions:
- Type some text in the screen tip box:
- Click the Copy icon at the top of the Rules pane (it’s the first of the 4 little icons at the top).
- 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.
- 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.
- 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.
- 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: