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

  • Question

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

    Friday, September 24, 2010 4:37 PM

All replies

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


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    • Proposed as answer by jason3555 Thursday, February 19, 2015 3:21 PM
    Saturday, September 25, 2010 3:00 PM
  • 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?


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force


    Hi Clayton,

    Thanks for the detailed response!  I was hoping you would chime in.  :)

    I actually implemented your technique for automatically generating unique file names a couple of months ago when you helped me on another form.

    Do you mind breaking down your instructions above into a little more detail please? 

    For instance, point number 1, is that done in the SharePont doc library itself?

    For point number 2, when you say promote strFileName to the form library, you simply mean to add it to the list of fields I am displaying in the SharePoint view right?

    As far as point number 3 is concerned I don't quite follow your instructions.

    TIA

    Saturday, September 25, 2010 5:32 PM
    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.

    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Sunday, September 26, 2010 6:12 AM
    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.

    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force


    Hi Clayton,

    I'm having trouble with the specifics in this particular step:

    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.

     

    I did the following:

    1. I added an action to query a data connection (the one I created in the previous step in which I checked only the ID field) and then for "Action", I chose "Set a fields value", for I selected the field I am using on my form to display the ID and finally for "Value", I clicked on the "fx" button, selected my field on the form and inserted this -  ReqNum = ID, but ofcourse I get an error immediately saying the ID does not point to a valid location path of a field of group.

    How do I do this in your instruction - "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).  "

    Monday, September 27, 2010 1:16 PM
  • Sorry to be bugging you Clayton, but can you please help out this noob?  :)
    Tuesday, September 28, 2010 7:14 PM
  • 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 connection.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force

    Wednesday, September 29, 2010 5:17 AM
  • 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


    Devster

    Monday, September 17, 2012 3:27 PM
  • 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!!!
    Thursday, February 19, 2015 3:21 PM
  • 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?
    Friday, June 26, 2015 5:25 PM
  • Jason, did you get two forms created one with the ID and one without the ID by using the solution above?
    Friday, June 26, 2015 5:26 PM