What better way to discover what Business
Connectivity Services is about than to dive straight in and create a
sample application? For this example, we are going to connect to the
Customers table in the Northwind database and
use it to create a SharePoint external list. When we have our customer
list in SharePoint, we will create an external column for our document
library and then use all we know to build a composite application.
For our solution we need to
Connect to the Northwind database.
Define an External Content Type.
Create an external list in our SharePoint site.
Create an External Column for our document library.
All of these tasks will be done from SharePoint
Designer, so without further ado, let’s open SharePoint Designer and
point it at our sample SharePoint site.
1. Creating an External Content Type
From the Site Objects list in SharePoint Designer,
you can see an External Content Types option. Selecting this allows us
to create a new External Content Type using the icon in the ribbon.
Figure 1
shows all the elements that make up our new External Content Type
including general information such as name and office type (Generic
List, Appointment, Task, and Post), operations, permissions, associated
external lists, and fields.
After naming the Content Type we now need to connect
it to our external data source by clicking the link next to the
External System label. This opens the Operation Designer page as in Figure 1.
Note
The external data source in this example is a SQL
database, but SharePoint Designer 2010 provides for connections to a
Web service as well as a .NET assembly.
The Operation Designer page in Figure 2
shows the page with our database connected. Creating the connection was
as easy as clicking the Add Connection button and providing the
database server, name, and credentials. You can see the list of tables
in our database in the Data Source Explorer. Now that we have located
our Customers table, we have to define the operations that will allow
us to interact with the data. Right-clicking the Customers table allows
us to select from all the operations available (Figure 3).
The first option allows us to define all the
operations at once. Selecting this option prompts a wizard that enables
us to define parameters and filters. We are doing a simple one-to-one
mapping of a table, so we don’t need to apply filters. Figure 4
shows the Parameters page where we can select the fields we want to
pull from our data source as well as field properties, such as display
name, if the field is read-only, and so on.
You may also notice the Office Property option under
properties. This allows you to map your inbound columns to Office type
properties such as first name, e-mail address, home phone number, and
so on. The reason you may want to do this is if you are creating a
Content Type using one of the Office types such as contact, task, or
other. Having these Content Types makes integration with the Office
clients incredibly easy.
After the wizard is complete, you will have a full set of operations defined for your data. Figure 5
shows us returning to our External Content Type summary page where can
see the fields we selected and the operations we defined.
We
have our External Content Type connected to our external data source,
fields selected, and operations defined. We are ready to save the
Content Type and put it to use.