By Ryan Keller
Using InfoPath Form Services with SharePoint is a great way to collect and manage data. You can even publish an InfoPath form into a SharePoint library, where all the collected data is stored and searchable. With InfoPath 2007 and Microsoft Office SharePoint Server 2007 being so closely intertwined, you can even use a SharePoint list as a data source in InfoPath. Suppose you have an extensive list of customers stored in a SharePoint list. You want to be able to use this information in a form you are designing, but the data changes frequently. It wouldn’t make sense to have to constantly update the list of customers in the InfoPath form and republish it to the server every time something changes in the SharePoint list, so why not use the data from the SharePoint list to populate your InfoPath form? This way, when anything changes in your customer list in SharePoint, those changes will automatically show up on the InfoPath form as well. Here’s how to link a SharePoint list to InfoPath:
1) First, add a new data connection by clicking Tools > Data Connections…
2) Click the Add… button in the Data Connections window
3) Select Create a new connection to: Receive data and click Next
4) Click on SharePoint library or list and click Next
5) Enter in either the URL of the site that contains the list, or the full URL of the list itself and click Next
6) InfoPath will contact the server and display all of the available lists. Choose the one you want to use as a data source and click Next
7) Select the field(s) you want to use in your form and click Next
8) Choose whether or not you would like to store a copy of the list data in the form template. This could be useful if you plan on using the form within InfoPath; however, if you plan on making the form a web-enabled form to fill out using the browser, you can leave it unchecked. Click Next
9) Give the data connection a name. By default it shows up as the name of the list you are connecting. Leave the box checked to Automatically retrieve data when form is opened. This way you can be sure the latest data is available when the form is opened each time. Click Finish
10) Once you’ve completed the Add connection wizard, you can close the Data Connections window
Now you can use the data in various controls within InfoPath. For this example, we’ll be displaying the data connection in a drop down list box:
1) In the Design Tasks toolbar on the right, click Controls
2) Drag a Drop-Down List Box control onto the form
3) Right-click the drop-down control and choose Drop-Down List Box Properties…
4) Under the List box entries section, select the option Look up values from an external data source
5) Choose the external data source you connected in the previous section in the drop down.
6) Next to the Entries field, click the Select XPath button
7) Drill down in the data source structure to select the field that contains the values that will be displayed in the drop-down. Click OK
8) Click OK again to close the Drop-Down List Box Properties window
9) Click the Preview button in the toolbar to test the form. If you receive an InfoPath Security Notice dialogue box, click Yes
If you preview the form, you should now be able to see the items from the SharePoint list displayed in the drop-down menu. This is just one of the many ways SharePoint and InfoPath can work together in order to make data collection and management easier.
Ryan Keller is a consultant with SharePoint 911