locked
Display "Created" and "Created By" in InfoPath Form View

    Question

  • I have created a form using InfoPath and published it to a form library on my MOSS 2007 server.  This form has 2 views - the default view is for users completing the form, and a second view that administrators can view to see the form plus some additional information I'd like to add to the bottom.

    This additional information is metadata about the form itself, specifically the "Created By" and "Created" values from the form library.  So, when the second view is displayed, the administrators should see the form as well as the name of the person that submitted the form and when it was submitted.

    I have found some information online about using a query data source to do this but I have had no luck.  I have created the data source to point the form library, to include data for the active form only, and to automatically retrieve data when the form is open.  I then opened my second view and inserted both of the fields using the data source pane on the right of the screen.

    So far this seems to be correct, however when I submit a form and then open it from the form library and view the second view, I do not see the additional fields for "Created By" and "Created' at all.  When I initialy inserted them into the form the application put them into a repeating section automatically, but I have also tried inserting them as non-repeating text boxes, and in that case even though I do see the fields there is nothing displayed in them.

    I have also tried using a Rule and a Refresh button to refresh the query (secondary) data source, but the data is still not displayed.  I'm sure it must be something simple that I'm doing wrong but I cannot figure out what I'm doing differently than all the examples on the web.

    Any help is greatly appreciated!
    Thanks,
    Chanda
    Friday, December 11, 2009 5:27 PM

Answers

  • Hi Chanda,

    I am not sure of the process you are following.
    But I was thinking that you could have 2 fields on the "Administrator view" one for storing the person who created the form and one for storing the time stamp when the user submits the form.
    You can get the name of the person who filled the form into the filed by following the post below:
    http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

    And to get the time stamp by writing a rule in the submit button on the "User View".

    Hope this helps.
    • Marked as answer by Chanda Cole Friday, December 11, 2009 10:36 PM
    Friday, December 11, 2009 6:57 PM
  • I think it's far less overhead and complexity to just store the submitter and submit date as data in the form.  You need to store the submitter data no matter what anyway so that you can perform many actions like in my blog here:

    InfoPath – Get user information without writing code (extended)

    Keeping track of the original submitter's ID is very important and very lightweight.  I have a field for that in every form I create (plus many other hidden fields to store identity information for conditional formatting purposes).  All you have to do is create a hidden field and set its default value to the function userName().  That's inredibly easier than creating a data connection back to the form library, querying it, retrieving ALL OF THE FORM library data, and then dealing with it as secondary data.  Remember, that secondary data from data connections does not store with the XML, so you'd have to use logic to parse through the entire set of data returned from SharePoint to match one of the fields with a field in your form so that you know which row is the right one, and then specify the fields you want to use within that row (created by and created).  This also will only work if every form in your form library is in the default view (or whichever view you tie the data connection to).  All of that is way more than just simply setting a field's default value to userName() and setting another field to the now() function as a rule on your submit button.  Just my 2 cents...
    SharePoint Architect || My Blog
    • Marked as answer by Chanda Cole Friday, December 11, 2009 10:36 PM
    Friday, December 11, 2009 9:53 PM

All replies

  • Hi Chanda,

    I am not sure of the process you are following.
    But I was thinking that you could have 2 fields on the "Administrator view" one for storing the person who created the form and one for storing the time stamp when the user submits the form.
    You can get the name of the person who filled the form into the filed by following the post below:
    http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

    And to get the time stamp by writing a rule in the submit button on the "User View".

    Hope this helps.
    • Marked as answer by Chanda Cole Friday, December 11, 2009 10:36 PM
    Friday, December 11, 2009 6:57 PM
  • Thanks for your reply,

    Here is a link detailing the process I'm following to create the query data connection:
    http://office.microsoft.com/en-us/infopath/HP100931601033.aspx

    It seems to me this should work to pull the information from the SharePoint list so that I don't have to complicate the form by adding anything else.  I will take a look at the link you provided as it might work, but I'd prefer just to pull the information from the SharePoint list rather than storing duplicate values in the form...

    Thanks!
    Chanda
    Friday, December 11, 2009 9:40 PM
  • I think it's far less overhead and complexity to just store the submitter and submit date as data in the form.  You need to store the submitter data no matter what anyway so that you can perform many actions like in my blog here:

    InfoPath – Get user information without writing code (extended)

    Keeping track of the original submitter's ID is very important and very lightweight.  I have a field for that in every form I create (plus many other hidden fields to store identity information for conditional formatting purposes).  All you have to do is create a hidden field and set its default value to the function userName().  That's inredibly easier than creating a data connection back to the form library, querying it, retrieving ALL OF THE FORM library data, and then dealing with it as secondary data.  Remember, that secondary data from data connections does not store with the XML, so you'd have to use logic to parse through the entire set of data returned from SharePoint to match one of the fields with a field in your form so that you know which row is the right one, and then specify the fields you want to use within that row (created by and created).  This also will only work if every form in your form library is in the default view (or whichever view you tie the data connection to).  All of that is way more than just simply setting a field's default value to userName() and setting another field to the now() function as a rule on your submit button.  Just my 2 cents...
    SharePoint Architect || My Blog
    • Marked as answer by Chanda Cole Friday, December 11, 2009 10:36 PM
    Friday, December 11, 2009 9:53 PM
  • Hi Chanda,

    Please take a look at this post
    http://www.infopathdev.com/forums/p/6541/44798.aspx

    Thanks.
    Friday, December 11, 2009 10:04 PM
  • Thanks to you both,

    After your explanation of the overhead involved in using the secondary data source to pull the created/created by values I agree it's easier to store the values in the form.  I followed the instructions in your blog to get the submitter's name, and Blue Diamond's suggestion to include the date using a rule in the submit options.  It works perfectly, thanks so much!

    Chanda
    Friday, December 11, 2009 10:39 PM
  • Hi Chanda,

    I have a suggestion if you want to get the data from form library and show in the InfoPath form when the form is on load.

    1) Create a web service and get the "Created" and "Created By" fields value from form library, query condition can be uthe form name or any unique key as you like.

    2) Deploy the web service to the SharePoint, make sure it uses the same port number as where the form library is.

    3) Add the web service as addition data source to the InfoPath in design mode.

    4) Call the web service when the form is onload.

     

    Hope this helps.

    Thanks,

    Feng Lin

    Tuesday, January 18, 2011 2:51 PM