Automatically setting file name when submitting InfoPath 2010 Form

After creating my InfoPath form and setting it to publish to a Forms Library in SharePoint 2010, I found that I wanted to fine tune the experience that the user has when submitting a form.

The first thing to change was the annoying dialog asking the user for a filename. Many users will have no idea what SharePoint is asking them for, or worse, they enter a name that’s already used by another form (and either overwriting it or getting an error).

To see what I mean, simply create an InfoPath 2010 form and set it to publish to a SharePoint 2010 Form Library. It doesn’t matter what fields and columns there are.

Now, click on Add Document in the form library and you should see your form, something like this:


Fill out your form and then click the “Close” button – which isn’t obvious for end users.


Although probably confused, end users will most likely pick “Yes” here.

The next dialog is really confusing:


SharePoint is asking for the filename to save the form as in the Form Library. However, unlike a more standard save dialog, this one doesn’t let you see what the existing files are named, so the users are given very few clues as what is expected.

Instead of asking our end users these questions, we can just setup a formula that will automatically determine the filename.

First, either create an InfoPath form that publishes to a SharePoint library or open one you’ve already created. Next, in InfoPath, go to the File menu (backstage) and select Info, and then click on “Submit Options”:


On the Submit Form drop down menu, select “Submit Options”:


The Submit Options dialog window will appear.

· Check the box to “Allow users to submit this form”

· Under “Send form data to a single destination”, choose “SharePoint document library”

· Click the “Add…” button in the “Choose a data connection for submit” area

        o Enter the address for the document library


        o And here’s what we’ve been looking for: a place to enter a formula that will create the filename for the users – enter what you want here. Remember, you can use a field on the form as well as other variables (such as date and/or time)

       o Also, select if you want to allow your users overwrite a form that’s already been submitted

       o Click Next

       o Click Finish

· Now click Advanced, so more options are displayed

      o Under advanced, you can select if you want to display a message if there’s an error and/or if the submit was successful

      o You can also choose what to do from there – Close the form, Open a new one, or Leave the current one open

Publish the form and now you should see something like this when you create a new form to submit:


Notice the buttons in the ribbon – there’s now a “Submit” button, along with the default buttons. That’s better, but it’s not quite what I want.

So, open the form back up in InfoPath Designer, and go to the File menu (backstage), select Info, and then click on Form Options at the bottom:


In the Form Options window, the first set of choices is for the form in a Web Browser:


Here is where you can set which buttons to display in the ribbon. Make any changes you want, click, and then Publish the form.


If you don’t want to use the ribbon at all, you can add a button to the form and set it to be the submit button.

Using InfoPath 2010 with SharePoint 2010 Content Types

There are a couple of ways to integrate Content Types with InfoPath forms libraries. I’m going to cover one scenario, but I’m sure there are more.

My scenario is that I want to submit a form to a SharePoint 2010 Forms library and align the data collected on the form to existing columns in my Content Type. Here’s a summary of the steps:

· Create a Site Content Type in SharePoint 2010 (my example is HR Forms)

· Create a Forms Library in SharePoint 2010 (my example is HR Forms Test)

· Add the Site Content Type to the newly created Forms Library

· Create a new form using InfoPath Designer 2010

· Publish the form to the form library, mapping the fields on the form to the existing columns in the library

That’s it!

Ok, now for some detailed steps:

Create a Site Content Type in SharePoint 2010

Go to the site in SharePoint 2010 where you want to define your Content Type (this will vary based on your requirements). For my example, I’m creating my Content Type in the root of my site collection, which is at http://intranet .

Go to Site Actions menu –> Site Settings –> Site Content Types.

At the top of the list of content types, click the Create link. You should see a page like this:


I’ve already filled in my Name “HR Forms”, selected the parent content type, and selected an existing group. Click Ok to create your Content Type.

You’ll then be returned to the list of content types – look for your newly created content type under the group that you either chose or created.

Once you locate your content type, click on it. This will bring up the Site Content Type Information page, which contains the settings for your content type. You’ll need to add columns to your content type, which is near the bottom of the window.

Once you’ve added some columns, your page should appear something like this:


Now that the content type is ready, we can move onto our next step.

Create a Forms library in SharePoint 2010

To create a Forms library, go to the Site Actions menu, and select “More Options”. A Create window will appear displaying all of the options of things you can create in SharePoint. If you click on the Library filter on the left, the window will only display libraries (as you’d expect). For our scenario, we need a Form library, so click on Form Library and fill in a name for the new library on the right. Your page should look something like this:


Then click Create. You should now see your forms library:


Add the Site Content Type to the newly created Forms Library

Our next step is to finish configuring the forms library (that we created in the previous step). To do so, go to the forms library and click on the “Library” tab in the ribbon at the top of the page. Then click “Library Settings” which will be near the right:


On the Form Library Settings page, you should see General Settings and then a Columns section. However, you won’t see Content Types. First, you’ll need to allow content types to be used with this forms library. To do this, click on the Advanced Settings in the General Settings section.

On the Advanced Settings page, you’ll need to set “Allow management of content types?” from “No” to “Yes”. This is the first setting at the top of the page. There are a lot of options on this page, but you’ll only need to change the first one for our scenario, so change it and click Ok to save your change.

Now, when you return to the Form Library Settings page, you’ll see Content Types immediately below the General Settings section.


Now, click on “Add from existing site content types” in that Content Types section. On the Add Content Types page, find the content type you created and Add it by selecting it and moving it to the “Content types to add” box, and then clicking Ok.


When you return to the Form Library Settings page, you should see your Content Type listed in the Content Types section.

Create a new form using InfoPath Designer 2010

The next step is to create the form in InfoPath. To do this, you’ll need to open InfoPath Designer 2010. When you open InfoPath, it should display the New window (if not, go to the File menu/backstage and select new):


In the new window, select “SharePoint Form Library” and click the “Design Form” button on the right. InfoPath will then create a new form for you to edit. Make any changes that are necessary, including adding fields that your form needs to collect from the user. Be sure to create fields for any Column that you’ll need to populate in your Content Type.

Once you’ve got your form the way you want, be sure to save it.

Publish the form

The next step is to publish the form so users can access it in SharePoint 2010. To do this, go to the File menu (backstage) and select the “Publish” choice on the left:


Now, click on the “SharePoint Server” option. (If you haven’t saved your form, you will be prompted to save it at this point.)

The Publishing Wizard will open. You’ll need to enter the URL of the SharePoint site:


On the next screen, you need to select “Form Library” from the choices:


On the next screen, you want to select “Update the form template in an existing form library” and then select the library that you created earlier:

On the next screen, you will need to align fields in your InfoPath form to the columns in your Form Library. Click Add and then select the field in the top of window and the matching Form Library column in the lower half:


Repeat this step for each field that you want to map to the Form Library columns.

When you’re done, click Next and then Publish. InfoPath will publish the form and then give a summary of the just published form.