SharePoint 2010 Cookbook: How to Create External Lists & Include Databases Using SharePoint Designer 2010

SharePoint 2010 adds many new features to Lists. In this article, we will take a look at how to create an External List. As you know, the External List is used for displaying content that comes from Business Connectivity Services (BCS). The Business Data Connectivity (BDC) Service enables SharePoint to display business data from back-end server applications, Web services, and databases. This walkthrough shows you how to create a model for the BDC service that returns information about contacts in a sample database.

Challenge:

We did not have External Lists in either SharePoint 2003 or SharePoint 2007, which was a limitation since we couldn’t directly access SQL Server databases to get data into SharePoint.  Now with SharePoint 2010, it is possible to create a list from other external sources with the help of external content types and External Lists.  You can connect with any external source and create a list. I will show you how to create a list from the SQL server database in this example.  The advantage of this is you can not only view but also insert, update, and delete using external content types.  You can create External Lists using SharePoint Designer 2010. In the first part of this post, I will demonstrate how to create an External List, and in the second part, we will look at how to create an External List, including a Database, with the help of SharePoint Designer.

Solution:

SharePoint 2010 has a new type of List called the External List, which is used to display data from Business Connectivity Services (BCS).

First, I will demonstrate how to create an External List that uses data from a SQL table through SharePoint Designer 2010.

  • Step 1: Make sure you created a Northwind database in SQL Server.
  • Step 2: We go to SharePoint Designer to connect the database with SQL Server as follows:
    • Click on the External Content Types menu on the left pane
    • Then, select the External Content Types icon on the top.
    • You will see a Connection window appear:
  • Step 3: Click on Add Connection button
    • You will see a dialog appear to select Data Source Type as pictured below
    • Of course, we will select SQL Server
    • After selecting Data Source Type, we fill in the SQL information fully, including Database Server, Database Name, and Secure Store Application ID as shown below:
    • Don’t forget to enter User Name and Password when BSC Secure Store is shown:
  • Step 4: After connecting successfully, you will see the Northwind database shown on Data Source Explorer below.
    • We will select a Table to create here by right-clicking Table Name and selecting Create All Operations:
    • A Parameter Configuration is shown after that; you can select any columns you need and click the Finish button to complete.
    • Finally, don’t forget to click the Save button after you’re done. This is pretty important, for obvious reasons.
    • Now, we have a Northwind database, as we expected.

I will show you how to create an External List, including a database, from SharePoint Designer. It’s very easy.

    • Step 1: First, we go to SharePoint Designer 2010 to select a site for configuring.

For example, I select the http://singlemoss2010 link

    • Make sure that we have configured BDC before. Don’t forget that we are getting data from BDC so we must have a database here.

For example, I created the Northwind database here.

  • Next, click on the External List menu on Ribbon to create a new list. You will see a Create External List form appear. You only need to fill in the List Name in the Name textbox as pictured below:
  • Step 2: Go to the site you selected for configuring earlier. We will see a new External List created by SharePoint Designer.
  • But you may be surprised when clicking on the new list since you will not see its database here. Don’t worry about this! This only means that you have not yet assigned access privileges to the currently logged-in user.
  • Step 4: To assign access privileges for a user, go to the Central Admin Page –> Application Management and select Manage service applications:
  • Click on the Business Data Connection Services hyperlink.
  • After clicking on BDC Services, you will see the database you created earlier. Please click on the Database Name to expand the context menu and select Set Permissions.
  • You should add users and assign access permissions for them here:
  • Step 5: After finishing the configurations above, you only need to go to the site and press F5 to refresh the page.
    • Now, everything is OK. You will have an External List, including a database.

Notes:

  • CAUTION: SharePoint 2010 External List throws a webpart exception when working with an external content type created in Visual Studio 2010.

I have created an external content type in Visual Studio which connects to a SQL 2008 database. Following is what I’ve covered:

  1. Created External Content types in Visual Studio 2010
  2. Wrote implementation for ReadItem, ReadList, Create and Update
  3. Deployed the content type through Visual Studio (Right click Solution name -> Deploy)
  4. Verified through SharePoint Designer 2010 that the content type has been added
  5. Added permissions for this ECT through Central Administration
  6. Created an External List using SharePoint 2010 (also created directly from the browser – Web Application)

2. Mapping External List Columns to Database Columns

  • Every column in the file you want to import must be mapped to an existing column in the prospects table in the Siebel Database or an attribute created for this purpose. If you import response or campaign data, you can also map to response and campaign fields. For information about mapping attributes, see Adding Additional Attributes to a List.
  • CAUTION: Make sure that you map every column before launching the import.
  • To map list columns to database columns in the prospect table:
    1. Navigate to the List Management screen > Lists view.
    2. Drill down on the list name.
    3. Click the List Import view tab.
    4. Scroll down to the List Import Format list and map every column to an existing database column in the prospect table or to an attribute created for this purpose.
    5. In the List Import Format list, save the format in one of the following ways:
    6. The first time you save a format, click Save as New.
    7. Save as New allows you to retain the original format and save the modified format separately. All saved formats appear in the List Management screen’s List Imports Formats view tab.
    8. Click Save to overwrite the original format.
    9. Use this save option if you make changes to the mappings and want to preserve them.
    10. After you save the List Import Format, perform the following steps to verify the columns that will be used for matching and updating.
    11. In the List Import view form, copy the name of the List Import Format in the List Import Format field.
    12. In the List Management link bar, click List Import Formats.
    13. Query for the name that you copied in the List Import view.
    14. In the lower list, you will see the columns that you mapped from the import file.
    15. In the Exact Match Column field, check each column from the list that you want to use for the exact match.
    16. NOTE: These settings are only used when you have selected Exact match or Exact and intelligent match as the matching approach.
    17. In the Allow Field Updates field, check any fields that you want to allow to be overwritten when using the Overwrite existing record match resolution.

See Also: