I want to display the ID of an Infopath form after submission to a doc library on SharePoint

How can I display the ID of an InfoPath form after I have submitted it to my doc library in SharePoint.  In other words I want to display the ID the next time I open the form (ie after the first save) as well as in the doc library in a view.

September 24th, 2010 4:37pm

In your submit button, do a double submit by doing this:

  1. Add a new retrieve data connection for the current form library
  2. Use my article here to generate your filename: InfoPath – Auto-Generating Filenames (you should always do this, but it's especially important when you want to retrieve the ID).  Also, be sure you promote the strFilename field to the form library so that you can use it for comparison
  3. In the Submit rule from above, be sure to add an action to query the data connection from step 1 (the query must occur after the first submit)
  4. The next step should be an action to "Set a Field's Value."  This is where you'll want to set the value of your form's ID field to the ID node of the secondary data connection WHERE strFilename (SharePoint) is equal to strFilename (InfoPath).  Here, you are using a filter to compare the filename saved in the form to the filename saved in the form library.
  5. Next, re-submit so that the ID is saved in your InfoPath ID field
  6. Display this ID field wherever you want in the form, but make sure it's read-only

To show the ID in your view requires no work.  The ID is automatically created in SharePoint, and the ID field is right there for you to use without doing any work.  Did you not see it?

Free Windows Admin Tool Kit Click here and download it now
September 25th, 2010 3:00pm

In your submit button, do a double submit by doing this:

  1. Add a new retrieve data connection for the current form library
  2. Use my article here to generate your filename: InfoPath – Auto-Generating Filenames (you should always do this, but it's especially important when you want to retrieve the ID).  Also, be sure you promote the strFilename field to the form library so that you can use it for comparison
  3. In the Submit rule from above, be sure to add an action to query the data connection from step 1 (the query must occur after the first submit)
  4. The next step should be an action to "Set a Field's Value."  This is where you'll want to set the value of your form's ID field to the ID node of the secondary data connection WHERE strFilename (SharePoint) is equal to strFilename (InfoPath).  Here, you are using a filter to compare the filename saved in the form to the filename saved in the form library.
  5. Next, re-submit so that the ID is saved in your InfoPath ID field
  6. Display this ID field wherever you want in the form, but make sure it's read-only

To show the ID in your view requires no work.  The ID is automatically created in SharePoint, and the ID field is right there for you to use without doing any work.  Did you not s

September 25th, 2010 5:32pm

  1. No, data connections aren't added to a doc lib.  You add data connections to the form template.
  2. No, it doesn't matter what is in the view.  You promote fields from the form to the form library when publishing the template.
  3. You just add an action to query the data connection.  If you implemented my solution for generating filenames, then you have a Submit rule that creates the filename, submits the form, then closes the form.  Now, you add some more actions to this rule BEFORE the close action, and the first thing you do after the first submit is query the form library data connection (from step #1) so that you can retrieve the ID of the form, and that ID only exists after it is submitted.
Free Windows Admin Tool Kit Click here and download it now
September 26th, 2010 6:12am

  1. No, data connections aren't added to a doc lib.  You add data connections to the form template.
  2. No, it doesn't matter what is in the view.  You promote fields from the form to the form library when publishing the template.
  3. You just add an action to query the data connection.  If you implemented my solution for generating filenames, then you have a Submit rule that creates the filename, submits the form, then closes the form.  Now, you add some more actions to this rule BEFORE the close action, and the first thing you do after the first submit is query the form library data connection (from step #1) so that you can retrieve the ID of the form, and that ID only exists after it is submitted.
September 27th, 2010 1:16pm

Sorry to be bugging you Clayton, but can you please help out this noob?  :)
Free Windows Admin Tool Kit Click here and download it now
September 28th, 2010 7:14pm

It's a lot of work explaining all of this.  Please spend some time trying it.  You have the guidance, and I guarantee you that it works, so now it's time for you to get your hands dirty.

When setting the field's value, you have to use the wizard in the function button (fx) to first select the appropriate field from the secondary data connection and then FILTER it where the dropdown selection matches the relevant field in the data connect

September 29th, 2010 5:17am

Clayton,

I have a similar situation/issue.   I have set a field to pull in the ID field "On Open."   I created a timestamp using the NOW function.   On open the timestamp field in the form compares to the published timestamp that I import via data connection.  

Every once in awhile the ID field does not import the ID value.  No rhyme or reason. 

Thoughts?

Clay

Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 3:27pm

This is an awesome approach Clayton.  I've played around with similar concepts before, but this is the most elegant way to meet the requirement that I've seen.  Thanks for the tip!!!
February 19th, 2015 3:21pm

Clayton, how did you prevent from two forms being created? One is being created without the ID, and another form with the ID in the filename?
Free Windows Admin Tool Kit Click here and download it now
June 26th, 2015 1:29pm

Jason, did you get two forms created one with the ID and one without the ID by using the solution above?
June 26th, 2015 1:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics