Skip Ribbon Commands
Skip to main content

Laura Rogers @WonderLaura

:

Quick Launch

Laura Rogers @WonderLaura > Posts > InfoPath: Using the ID field as the Form Filename
Hi everyone,
My blog now has a new URL!
You can now find me at http://www.wonderlaura.com
November 15
InfoPath: Using the ID field as the Form Filename

It is a common requirement of InfoPath projects to make a form in a form library, where the name of the XML file is the same as the ID of the item itself.  There are several methods I’ve seen out there, and I’m definitely not the first person to blog about this.  One method is in which you create a data connection back to the form library itself, pull in all the items, and calculate the MAX ID + 1, to create your new form name.  That’s an okay method, except that I’ve seen it bomb out once your library view gets to over 1,000 items.

Here’s a way of doing it, which is pretty simple:

  1. Create a field in your form library form, called something like AutoID, as a text field.
  2. Set the default value of AutoID to be the function Now().  Uncheck the box to refresh the value.
    MA14SP-30
  3. Create your submit connection to use the AutoID as the file name
    MA14SP-29
  4. When you go through the publishing wizard in InfoPath, promote the AutoID field up as a column, and check the box to “allow users to edit data in this field…”
    MA14SP-32
  5. Create a SharePoint Designer workflow that runs on create:
    MA14SP-33
    The steps are:
    Wait for field change in current item
    Wait for change in document check out status
    Set field in current item (use the string builder to put the ID field with a .xml next to it)
    Set field in current item (use the field picker to just pick the ID field)

Results: when a form is first filled out and submitted, the filename will be set to a long set of numbers that represents the current date and time.  This is temporary.  As soon as the XML file is first created, the workflow will run, and will change the filename and the AutoID field to the ID of the item.  Then, next time someone opens it up and submits it again (if you want them to be able to-see the checkbox at step 3), it will submit as that same AutoID number.

MA14SP-34

 

Comments

Bhavesh

Hi Laura,  Great workaround and very well written article ! I usually use Max ID+1 to auto numbering. As you mentioned you have seen it bombs out after 1000+ items. Is that because limit of number of items in the view ? I have not seen this issue before so wondering if I need to change those forms to use above method at some point.
Shane YoungNo presence information on 11/16/2011 9:48 AM

Laura

Bhavesh, Here's how you can do something similar in 2010 without the "max": When you create your data connection to get all the items in the library, the data connection wizard will let you choose a sort order.  Sort by ID descending.  That way, you can look at the value in the ID column and it will automatically show you the highest number, without having to do a max calc.
Laura RogersNo presence information on 11/23/2011 8:57 PM
​I have disabled any new comments on this, because my blog has moved to a new site.  Please go here: http://www.wonderlaura.com
RSS FeedFacebookYouTube
 

 Our Books for End Users