myspace live counter
Generating a unique form number - a SharePoint counter - Geeky Girl - Site Home - TechNet Blogs

Generating a unique form number - a SharePoint counter

Generating a unique form number - a SharePoint counter

  • Comments 5
  • Likes

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.

Photobucket

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.

Photobucket Photobucket

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.

Photobucket

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.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • You can't use out of box ID ???

  • 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.

  • 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"

  • Hi Jessica.

    Thank u for ur post. it was totally useful:)

  • Ho do you make it display in the NewForm when its loaded to create a list Item?