Generating a unique form number - a SharePoint counter
I’ve had a request to expand on my post about generating automatic numbers for InfoPath forms. I was asked to go into more detail about how to set up a SharePoint list to act as a counter.
Go to the SharePoint site where you have your document library and create a custom list by the standard process. There are a couple of different ways to do this. You can click Site Actions, then create. Or you can click on lists to get a list of all the lists on the site, and then click create. Or you can click on view all site content, then create. Either way, you will be taken to a menu screen offering a selection of things that could be created. The top link in the fourth column is custom list. Click this.
Now you have a new list with only one column showing, title, and no elements.
Click on settings and then create column. Add a column that contains a number with no decimal places. I’ve called this count. It doesn’t really matter what you call this column, so long as you remember the name.
Once you’ve got the column, add an element to the list. It doesn’t matter what you put in the title field but you need to put 0 in the count column (assuming there are currently 0 forms in your library).
That’s your counter made.
Now, open up SharePoint Designer. You’ll want to create a new workflow. Select the options to attach this workflow to the form library you want to set the auto-numbering in. Disable the options to allow users to manually start the workflow or to start the workflow when items change. Either of these would mess up your numbering.
Click next to get to the next screen in the wizard. This is an extremely simple workflow that only requires two actions. Click on the action button and add the inbuilt actions do calculation and update list item. Click on the first blue “value” links in the do calculation action, then click the function button that appears. This gives you the opportunity to choose an existing value. For source, choose your counter list with the count field as the field. Now SharePoint needs to know which item to bring back from this list, so set the field to be the ID field and the value to be 1 (since there’s only one item in this list). For the second value, just enter 1.
In the update list item action, click the blue this list. From the drop-down menu, choose the counter list. Add a field to be updated and choose the count field, selecting as the new value the calculated value (from the workflow data). Again, you need to specify the exact list item. Select the field ID and the value 1.
Then click finish. Now your counter will increment every time a form is added to your library. You can now reference this list from your InfoPath forms to create the form ID number.
Comments
Anonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
If you want a unique document ID, there are problems if you move forms between libraries. The inbuilt SharePoint ID is only unique to a document library. Yes, there are potential solutions to this problem using the inbuilt ID. My post is proposed as a solution, not the only one. The benefit of using a counter is that you can have multiple submission rules. Perhaps your form goes to one library if a total field is less thatn 100, another one if it's greater. You could have the same workflow on each library and forms would end up with a unique ID, even if they are stored in different libraries.Anonymous
June 17, 2010
Could you please explain further how we can reference this list from an InfoPath forma to create the form ID number? After creating the list by following your example, I tried to bind a Textbox on my InfoPath form to the list. But got the following error message: "binding a non-repeating control to a repeating field or group is not supported by InfoPath Forms Services. To fix this problem, bind the control to a non-repeating field or group"Anonymous
August 26, 2011
Hi Jessica. Thank u for ur post. it was totally useful:)Anonymous
March 27, 2013
The comment has been removedAnonymous
April 16, 2015
Thank you very much I appreciate the pictures as reference.Anonymous
January 18, 2016
This work with only one user create a new item, but when two user create at the same time a new item we have a big problem.Anonymous
January 18, 2016
This work with only one user create a new item, but when two user create at the same time a new item we have a big problem.Anonymous
February 23, 2016
This was great and exactly what I needed. Very simple.