Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Populating form data from SharePoint List Views

Populating form data from SharePoint List Views

Rate This

The SharePoint list data connection in InfoPath is a great declarative way to bring in data from a SharePoint list, but it does have some limitations.  For those willing to put in a little extra effort, there’s much more that can be done with SharePoint lists: you can bind to views based on these lists. Here are the steps for creating the connection to a list view.

First, let’s get the URL:

1. Navigate to the SharePoint site that contains the list, for example:
http://contoso/sites/sales/Sales%20Contacts/Forms/AllItems.aspx
2. Go to “Modify settings and columns”
3. Copy the List={GUID} portion of the URL and paste this into a buffer like a Notepad window.
4. In Notepad, create the following URL (the blue portion us taken from the step 1 URL, and the red portion must be added.

http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={GUID}&XMLDATA=TRUE&noredirect=true

This will return an xml file that can be used in an XML file data connection, as if it came from a file system.  After this, you can use the URL as the location of an XML data file when creating a data connection.

 

Two caveats:
- Form users must have read access to the SharePoint list.
- During creation of the data connection, do not include the file in the form template, as it should be dynamically generated from the SharePoint list.

 

Some tricks:
1. When you’re in “Modify settings and columns,” if you click on one of the views in the list at the bottom, you should note that the URL is “enriched” with &View={ANOTHER_GUID}.  If you would prefer to use the columns from that view, you should similarly enhance the URL you use above.
2. You can also use the url to filter data rows based on column values. For example:

http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={115BC7B7-0A82-403E-9327-F3C73E6D37F3}&XMLDATA=TRUE&noredirect=true&FilterField1=xd__x007b_52AE1EF8_x002d_28E7_x002d_4CE4_x002d_AE23_x002d_54E23E80DDB5_x007d_&FilterValue1=Approved

Note: be sure to remove the “ows_” from the beginning of the FilterField ID.

 

With this filter, the XML file returned will be filtered to only display those projects that have been approved.  Without the green portion, you would see all the projects.

 

In order to populate other fields with data from WSS, you create the secondary data source just like above, then in form code or script, you can use GetDOM(“dataSource”) and walk the DOM normally, updating the main DOM as appropriate.

 

Ed Essey
Program Manager

Leave a Comment
  • Please add 8 and 4 and type the answer here:
  • Post
  • Hi,

    It may be just my browser, but it appears that the URL examples seem to be truncated.  Could you re-post the full URLs in the comments section?

    Thanks,

    William H

  • Sure:

    1) http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={GUID}&XMLDATA=TRUE

    2) http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={115BC7B7-0A82-403E-9327-F3C73E6D37F3}&XMLDATA=TRUE&FilterField1=xd__x007b_52AE1EF8_x002d_28E7_x002d_4CE4_x002d_AE23_x002d_54E23E80DDB5_x007d_&FilterValue1=Approved

  • Hi there. Thank you so much for the tips. It worked for me really well..until I convert the view page to XSLT Data View in FP.

    I had to convert it so I could use the grouping filter in FP.

    ie) a and (b or c).

    When I open the *.iqv file, it launched the excel but then give a alert saying "Unable to open"

    I thought it may caused by typo but when I tired again..before and after convert the webpart, it clearly does not like that.

    Could you please advise me on this matter?

  • Hi,

    Superb article,  it gave me answers for most of the doubts that i had in my mind :)

    I just want to know if we can dynamically alter URL for secondary data source.

    Say i want to create filter based on the values selected in another field of my infopath form...

    is it possible ....

    Regards,

    Sudhir Kesharwani

  • That’s great!  And you can get a preview of the filter just by popping it into a URL and check it out. Except.. How do you handle special Characters? I have a SP list with a column that looks up into another list. That’s the field I want to filter. So my filter string looks like this:

    &FilterField1=Customer&FilterValue1=3;#New England Bio Labs

    This above filter doesn’t work. I suspect that it’s because of the ID and delimiter at the beginning ie: “3;#”.  

    Any suggestions?

  • http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={115BC7B7-0A82-403E-9327-F3C73E6D37F3}&XMLDATA=TRUE&FilterField1=xd__x007b_52AE1EF8_x002d_28E7_x002d_4CE4_x002d

    How might I apply an XSL style transformation on the returned xml?

  • Sorry for asking such basic question but I need exactly what has been mentioned in this article. I have created the url and the data connection but I dont know how to show it on the form. Could anyone please ellaborate on this.

    thanks!!

  • the url I am using is

    http://mossvpc:1586/_vti_bin/owssvr.dll?Cmd=Display&List=%7BD66DCB51%2D80B0%2D43AB%2DB80B%2DCD7D23E63B09%7D&View=%7B6D0CEF69%2DF899%2D40D0%2D86B2%2D6E01CC7D9CA1%7D&XMLDATA=TRUE

    I hv extracted it the same way as given above

  • Is there a limit on the number of elements a share point list can have?

    I have a list with around 300 items (rows) and 4 columns but when i try to use this list to bind to drop down column i get only about 100 returned.

    Is there a way to oversome this?

  • Hi c10,

    Is there a limit on the number of elements in a SharePoint list? There may be - but you may want to post that question to a SharePoint blog.

    However, the behavior you are seeing in InfoPath is expected. The items that are returned in a data connection are based on the default View in SharePoint. Each view in SharePoint, by defauly, limits the number of items to display to 100 - hence you only get 100 items returned.

    To workaround this:

    - Navigate to your SharePoint list

    - From the View dropdown choose Modify this view

    - Scroll to the bottom and expand the "Item Limit" section

    - Change 100 to something larger than what you would expect this list to store (i.e. 500, 1000, etc.)

    I hope this helps!

    Scott

  • Hi, I am very new with Infopath, so I apologize for the simplicity of the question.  I am using this code to essentially create a sharepoint/infopath based mail merge.  It is working GREAT, except I can't move to the next record.  Any suggestions?

    Thanks in advance!

    Wendy

  • Can I put a variable in the URL - i.e. a field in the InfoPath form?  That way the filtered value in the URL is populated by a choice the user makes on the form?  I'm trying to populate a repeating table from a SP list that only includes the items in the list for what they select.  So if the list contains detail for all projects, when they choose a project on the form, the repeating table is populated with only the detail for the project chosen.  I've seen examples using custom code, but I don't have VS tools for Office and I thought this would be possible out of the box.  Am I wrong?

    Thanks,

    Matt

  • Hello,

        I'm experiencing a weird behavior with the way the data connection is reading the XML file in my drop down controls. When I attempt to set the "Entries" field to "z:row", I am prompted with the error "You must select a repeating group or field."

        I have another form where I followed the same directions you outlined above, but I generated a resource file, and the "z:row" field is indeed a repeating field and works just fine.

        Is there a reason why this data connection is pulling the "z:row" field as a non-repeating? Am I missing a step? Thanks in advance - K

  • Hello - looks like it's been a little while since others have posted, but thought I would ask anyway.  We're trying to include a multi-line column from a list into an Infopath form.  I successfully generated the url as shown above, and the url does return xml data in a browser.  The url looks something like this:  http://oursite.com/ocio/cis/gitmeet/_vti_bin/owssvr.dll?Cmd=Display&List={7B30642C-A7E2-44AF-95C2-4AFF5E13461B}&XMLDATA=TRUE

    However, when trying to create a Receive data connection in Infopath, the wizard will not accept the url -- "unable to connect to the sharepoint site."

    Thanks.

  • Hi jhillppc,

    Are you able to connect to a list (on the same site) that does not contain a multi-line column? I don't believe this is an issue with that column type as I can connect in InfoPath and display the multi-line data without issue so something else may be occurring.

    Are you familiar with the network tracing tool Fiddler? You can get it here (http://www.fiddler2.com/fiddler2/version.asp - click the Install Fiddler2 link) and then you can start this while trying to create the connection. This is a network tracing tool but it only traces HTTP traffic. Maybe what you see in this trace will point you in the direction of the issue.

    Scott

Page 1 of 7 (104 items) 12345»