Infopath 2010 : Maintain a form name

When you submit an Infopath form you need to choose a filename often calculated to be sure is unique. When you submit a form which already exists you need to know the file name to resubmit with the correct name. With Infopath there is no way to know the name of the current form.

To bypass this disadvantage, I use a hidden field named “filename” which will contain the name of the file. I set this field value at the first submit and reuse it for all following submit.

For this example, the field is visible but usually I hide it.

I add a new data connection to the list where I submit the form and set the file name to the value of my field Filename.

In submit option, I choose to perform some action rules on submit.

And I setup the following action rules: First I look at Filename field value, if it’s blank I set it to a new value “My file”. Next, I submit the form with the data connection created just before.

I publish my form to the SharePoint Server.

Set the server name.

Publish as a site content type.

Create or update a content type.

Choose a form library where my form template will be uploaded.

Add some fields which will be added to the site content type.

I add the Filename to make it available on the list.

And I publish my form.

On the SharePoint list settings where the forms will be submit I add a new content type.

I add the content type created previously in Infopath.

On Sharepoint Designer I add a new workflow on the list to maintain Filename field.

The workflow is to set Filename to the name of the file.

I check to start the workflow when an item is created or changed to maintain the Filename on each event.

Now, when you resubmit a form you replace the preceding version because you use the same name. And when you renamed it and resubmit it, the Filename field is update and you replace the old version too.


Infopath 2010 : Display one item at a time from a repeating group

Suppose you have a repeating group and you want to display only one item from the group at a time. Moreover, you want to be able to add a new item displaying only this one.

For this you need to know the currently displayed item and be able to identify uniquely each item.

Create the data source like this. With in particular a “CurrentItemID” to know the ID of the item to display and a reapeting group with a unique identifier “ItemID”.

Set the “CurrentItemID” default value to 1 to display for the first element on load.

The default value of the “ItemID” field must be an incrementale number. Therefore calculate the value from the previous field + 1. For this use the function button and insert the following formula: “count(../preceding-sibling::my:RepeatingGroup) + 1”.

Next add a rule on the repeating group which will be triggered when a new item will be inserted. This rule set the current item id to the value of the new item id.

For this select the repeating group in the field section and choose “Home”/”Manage Rules”¬†on the and add a new action rule :

Next construct your form like this:

The repeating group is inserted two times : The first to list the item available and the second to display the current item properties.

On the first occurrence, I set the default value of the button to the current item id following by the current item name.

You must add a new action rule on the button. This will change the current item ID to the selected item id.

On the second occurrence, you must add a formatting rule to only display the current item properties.

Launch the preview. The list of the available items is on the left and the current item is on the right.

When you choose an item by click on the left, the properties of the item appears.

When you choose to “Insert item”, on the right a new item appears and you can complete the properties.