Thursday, 11 July 2013

Data Connection in InfoPath 2010

In a previous post I covered how to create an external content type and expose the data in a SharePoint list (External List).

In some cases simply exposing the data from a backed data source in the SharePoint list may be enough to meet your requirements.

However you may need to take it a step further and use the external list data to populate the choices for another field in a different SharePoint list.

A good example of this would be a list of customers, the list may be maintained centrally in for example a SQL database. Rather than duplicate that list and maintain two sources you can simply create an external content type and an external list to pull that data in to SharePoint.

Now the data is in SharePoint I may have another list that for example logs sales enquiries, on logging an item in this list I want to have a drop down to choose from for the list of customers.

If the list of customers is stored in a SharePoint list via the external content type, all I need is a data connection within InfoPath for the list to populate the choices with the customers data from the list.

If using the SharePoint as the central location for storing the data then you can ignore the reference to the external content type and just use the data connection in InfoPath to display the data from the SharePoint list in exactly the same way.

The context of the example below is of the customer names list I mention above.

So assuming you have your external list with the data required created, open the list we want to add the cutomers drop down field to in InfoPath.



Under the data tab select "From SharePoint List", you can see there is also the option to pull data from web services.




Select the site in which your external list containing the customer data lives.




Select the SharePoint list containing your data




Select the column you wish to use, in my case I only have one field but if the cusomer contact had multiple fileds like name/address/telephone I would only choose the customer name as thats the data I want to use in my drop down.







Name the data connection (you will see this name displayed in InfoPath when connecting to the data source).



Depending on where your SharePoint lists are stored - e.g if the data connection is connecting to alist in another web application you may need to convert your data connection to a connection file.

You will need to create a data connection library first - the out of the box template will be available under libraries.



Paste the URL of your data connection library and add the name your connecton file on the end followed by .udcx




You should also check your InfoPath Forms Services settings in Central Admin and enable "Allow cross domain data-access"

This all depends where the data you are connecting to is residing.


Now you have a data connection to the SharePoint list containing the data, create a field to display the choices.







Open the field properties and select the option "Get choices from an external data source"





From the data source drop down, select the data source just created to the SharePoint list.




Ensure "Value" and "Display name" are set to the column you want to display in the field.


 



Yoour drop down filed or multiple-selection filed will now contain choices pulled from the SharePoint list data connection.

A simple way to use centrally managed data (either managed directly in a SharePoint list or external data source) in multiple lists, removing the need to maintain any given list of data in multiple locations.

Thanks for reading,

Matt

1 comment:

  1. Hi,

    I can't get this to work using drop-dow list options. Is it me, or is this method restricted to only multiple selection controls?

    Bonnie

    ReplyDelete