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 2 and 4 and type the answer here:
  • Post
  • Thanks! Using the url trick i was able to solve a sorting problem with my drop down content bound to an SP List.

    Drop downs in Info Path web forms were sorted in creation date order, instead of alphabetical order. Binding to the returned xml file instead of directly to a list solved my problem :)

  • Hello to all... this is a great articvle and i can almost use it.

    I have a sharepoint list and a form that queries that list using a data connection. The list is already sorted but when the drop menues get populated in the web-form they are not sorted.

    When you say "Go to modify settings and coloumns", where do you mean? My list URL shows this:

    http://collab.safeway.com/it/Contentmgmt/Lists/Consumer%20Protection%20Multi/Allitemsg.aspx

    I dont see anything containing a GUID or "_vti_bin...".

    Where do i get the GUID?

    Thanks a bunch and any help is appreciated.

  • This probably isn't the right post for this but maybe somebody can point me in the right direction.

    I'm using infopath 2003 with sharepoint 2007.  

    I have a form with a drop down list that uses a column from a sharepoint list as a data source.  

    The column has numerous duplicates but I'm trying to retrive a unique list.  

    I've been trying trying to stumble my way through trying to create a filter but haven't had much luck.

    Any help or suggestions would be great I haven't had much with the posts I've found so far.

    Thanks

  • Is there a way to specify the row from a list that data in the columns are used to populate the infopath form.  In other words, I have 8000 employees and want to populate a portion of a form with info from a SP list for a specified employee.  How can I tell the infopath form what employee I want to pull from?

  • Hi -

    We have used your "View" method to bind only a view of a list to a control many times and it works beautifully.  However, I recently did the same thing on a list that is a content type, and the results were not as expected.  I created a view of the list, selecting only the columns I wanted to choose from on my InfoPath form, but when I brought up the form in Infopath and tried to bind to a control, other columns were there (from other views) and some of the columns I wanted were not.  Does this method not work with a list that is created using a content type?

    Thanks,

    Shelly

  • Hey Scott,

    How to use ur technique for Accessing Subfolders via secondary data connection ...i have folders in my Form Library and when i make a data connection from infopath to the library it works only at the root level and does not work inside the folder ie it does not get value when the form is inside a folder..any idea how can i solve this issue

  • Hi sharepoint99,

    I don't know of any way to get this process to work with subfolders in a library.

    Scott

  • The list I am accessing has a lookup column in it. It is this column I am interested in.  When the data is displayed in my browser infopath form, the lookup ID and Value are displayed.  I.E. 23;#BOM.  How do I just retrieve the Value? (BOM)

  • This is great and it works, but when I update data in the list, the data that is in the form is not updated, is still contains the old data, even data that has been deleted from the list.  I was hoping it would be dynamic but it seems to be static.

  • Hi MarsdeNation,

    When you setup the data connection you want to make sure you choose the option "Access the data from the specified location" - this is not the default option. As such, if you left the default option (Incluse the data as a resource file...) then the data will not automatically refresh.

    Scott

  • hi there, thanks for this useful post, i'm able to see the data when previewing in infopath as well as when pasting the URL to the browser's address bar but once i'm loading it inside an infopath web part, i'm getting this error....

    An error occurred querying a data source.

    Click OK to resume filling out the form. You may want to check your form data for errors.

    Hide error details

    XML data that is required for this form to function correctly cannot be found.

    An entry has been added to the Windows event log of the server.

    Log ID:5566

    Correlation ID:6558c56a-e6e5-4c6d-80fc-95af77785a5f

  • Joel, do you still have this XML Data problem?

    I too have this problem. The form and code work fine when opened in infopath (on the sharepoint server) and displays/filters the correct values, but when published to my sharepoint site, it opens and shows all values, except when I select one from the first column, it gives me that error. Cannot find anything in the event logs on the server.

  • Ello ello ello

    I have an SP list I am querying using this XML method (i could use another but i quiote like this way) problem i am having is the drop down being populated is coming from a multi line field in SP. The reason for the SP being multi line is that when the user makes a selection i want a number of drop downs to populate based on the selection, therefore tis better i have once row per initial selection rather than a new row (or even table) for every possible answer / question respectively.

    Anyway the problem i am having is that my results when displayed in the combo box are all displayed on one line and i would like to seperate them, i have tried turning the field into rich text rather than plain text but this just displays the HTML . I did think of looping through the data and inserting a new line every time it find </br> but i think this is inefficient and also my coding skills are really not up to scratch for something like that.

    Any suggestions??

  • Thanks for the article, I realise you wrote it many moons ago.

    I am trying to implement and have read most of the posts but can't get the final bit.

    I have data pulling into SharePoint from an InfoPath Form.

    The default view only shows 100 items and that's the way the client wants it.

    However in the form I want to see all list items in the drop down.

    I have created a dedicated view and copied the GUID in the manner you mentioned.

    My issue is that it still appears to show the 100 items when testing in the browser:

    xxxxxx.sp.xxxxxxx.net/.../owssvr.dll{AAB70B32-4E77-4A79-8212-7D42CE598181}&view={8557385C-3578-4675-A45C-805A5E6CAAB5}&XMLDATA=TRUE&noredirect=true

    Am I screwing up the syntax here ?

    the List and View Guids are different but if I remove the 'view={8557385C-3578-4675-A45C-805A5E6CAAB5}' section I basically get the same result despite the View showing all 200 list items.

    Help Appreciated

  • Hi Durbs-99,

    I don't believe I am able to reproduce what you are seeing - here is what I did for a test:

    - Have a custom SharePoint 2007 list with 20 items

    - My default view for the list shows the items in groups of 5

    - I created a new SharePoint view that shows all items

    - In my XSN, I added two data connections:

    LimitedItems:

    http://servername/_vti_bin/owssvr.dll?Cmd=Display&List={4A837605-81CD-4F27-9C3B-4A6EEF62B379}&XMLDATA=TRUE&noredirect=true

    AllItems:

    http://servername/_vti_bin/owssvr.dll?Cmd=Display&List={4A837605-81CD-4F27-9C3B-4A6EEF62B379}&View={D826BE04-4346-44DB-9277-018B59FDAFB0}&XMLDATA=TRUE&noredirect=true

    - Added 2 dropdown list boxes to my InfoPath Form Template

    - Bound the above data connections to the dropdown list boxes

    - Published the XSN to my server

    - Opened it in the browser - result: one showed 5 and the other showed all 20.

    Out of curiosity what happens if you just drag the data connection to your view as a "Repeating Table" - this makes it easier to see how many items are truly being returned.

    Scott

Page 5 of 7 (105 items) «34567