Chapter 4. Business Connectivity Services

Business Connectivity Services (BCS) is a much-evolved version of the Business Data Catalog in MOSS 2007 (BDC). With BCS, you can now read as well as write to external systems. There are various ways to accomplish this, but to begin with you can simply define BCS with one simple equation as

Business Connectivity Services = Business Data Catalog (MOSS 2007) + much more!

What Will You Learn in This Chapter?

  • BCS terminology

  • Introduction to Business Connectivity Services

  • Setting up BCS on your SharePoint 2010 installation

  • Creating External Content Types (ECTs) using SharePoint Designer 2010

  • Authoring ECTs using Visual Studio and a .NET assembly connector

  • BDC runtime

  • BDC and Office integration

  • Relevant Windows PowerShell commands

Software Prerequisites

To get the most out of this chapter, you'll need the following software:

  • SharePoint Server 2010 Enterprise Edition

  • SharePoint Designer 2010 x64

  • SQL Server 2008 R2 x64 or SQL Server 2008 x64

  • Adventure Works Database (SQL Server 2008 or R2), downloadable at http://msftdbprodsamples.codeplex.com/

  • Office Word 2010 Professional Plus

  • SharePoint Workspace 2010 (Office Professional Plus)

It's a lot easier to learn about a new system if you're familiar with the terminology, so let's start with the common terms you'll encounter, in both their full and short form, in this chapter.

BCS Terminology

  1. Business Connectivity Services: BCS is a set of services that facilitates the connection between SharePoint solutions and external systems. BCS architecture includes BDC services, BDC service data, Secure Store Services, the BDC runtime, and more.

  2. Business Data Connectivity (BDC) Service: This is what used to be the Business Data Catalog in MOSS 2007. The BDC in SharePoint 2010 is a service that acts as a bridge between business data and a SharePoint site. However, it still depends on the Metadata Store and it helps you to design the external system model. The Metadata Store is used to bring external data into SharePoint or Office.

  3. External System: This is your various databases, web services, and so forth.

  4. External Content Type (ECT): Newly introduced in SharePoint 2010, the ECT is a much-evolved version of its predecessor, what was called an entity in MOSS 2007.

  5. External List: Also new in SharePoint 2010, an external list is nothing but a SharePoint list that is used to display data from an external system in SharePoint.

  6. BDC Model: This is basically an XML metadata file that contains definitions and details about connection settings, the authentication mode, and available ECTs. A BDC model file is uploaded to the BDC Metadata Store.

  7. BDC Model definition file: The physical XML file that contains the metadata information mentioned in the BDC Model description.

  8. Type Descriptor: A type descriptor, as the name suggests, describes a data type. Here, however, it is a data type that's specific to BCS and completely independent of WCF, SQL Server, or .NET connector data types. It is reusable across all data sources.

Introduction

If you've worked with the Business Data Catalog in MOSS 2007, you know that it facilitates presenting LOB[10] data within MOSS 2007. People often ask, 'Why use the BDC when the functionality can be achieved by writing custom code?" But the BDC does a lot more than bringing LOB data into MOSS. If you are new to the BDC, see http://blah.winsmarts.com/2007-4–sharepoint_2007__bdc_-_the_business_data_catalog.aspx to learn the basics.

However, the BDC in MOSS 2007 does come with a few limitations.

  1. It's read-only – BDC entities, web parts, lists, and so forth provide read-only functionality.

  2. Understanding the data isn't easy– Implementers of the BDC need to have a thorough understanding of the underlying XML data structure and its elements.

  3. Insufficient tools – Though there were a few tools available to build a BDC XML structure (model), it was not always easy.

  4. Lack of client integration – There was no way to integrate data with rich client applications such as Word or Outlook.

Not only has Business Connectivity Services addressed these limitations, it also comes with additional features. Let's look at some of the major capabilities and enhancements in BCS.

  1. It's read / write capable – You can perform CRUD[11] operations on the external systems either using Office applications or SharePoint external lists.

  2. Familiar UI– In the earlier version, you had to rely on third-party tools to work with the BDC. Now you can work in an environment you are very familiar with, such as Office (Outlook, Word, and SharePoint workspaces) and SharePoint (lists, web parts, profile pages, and so forth).

  3. Good tools– There has been significant improvement in tools, as well as some new ones that enable both no-code and code-based solutions.

    1. No-code connectivity to external systems: You can perform operations on external systems without writing any code for simple requirements using SharePoint Designer 2010. SharePoint Designer 2010 can perform many more operations compared with its predecessor.

    2. Advanced and custom development: You can use Visual Studio 2010 to meet more complex and specific custom requirements.

  4. Connectivity options – There are more options to connect with data. You can use WCF services or .NET assembly connectors in addition to web services and databases.

  5. Rich-client integration – You can use external lists[12] within Outlook, Word, or a SharePoint workspace.

  6. Offline Access – You can work with data in offline or cache mode and synchronize with external system(s) when online.

  7. External data governance – Using Business Data Connectivity you can access data securely and audit and perform management tasks from one central location.

  8. Search – SharePoint enterprise search offers look up (discover) and index functionalities to the data in your external system.

Well, that looks pretty impressive doesn't it? But do you get all this functionality by installing any flavor of SharePoint 2010? And what do you have to configure to get it all to work?

Note

When we say BDC, we are referring to Business Data Connectivity in SharePoint 2010, unless otherwise specified as MOSS 2007.

Setting Up Business Data Connectivity Services

BDC is part of the new Service Applications model in SharePoint. BDC arrives preactivated with installation of SharePoint, and it creates a specific database with name Bdc_Service_DB_<guid> on the same database server selected for SharePoint installation. Let's begin by creating a new BDC Service Application and then configure it.

Set Up a New BDC Service Application

To create a new BDC service application, you need to have Farm Administration privileges. Open Central Administration

Set Up a New BDC Service Application
Creating a new BDC Service Application

Figure 4-1. Creating a new BDC Service Application

In the Create New Business Data Connectivity Service Application window, enter a new Service Application Name, Database Server, and Database Name, and choose the Database authentication mode. Set the Failover Database Server[13] name, and choose an existing application pool or create a new one for the BDC service application to run in, as shown in Figure 4-2.

Configuring a new BDC Service Application

Figure 4-2. Configuring a new BDC Service Application

Once the new BDC Service Application is created, you can manage it through Central Administration

Configuring a new BDC Service Application
Manage BDC Service

Figure 4-3. Manage BDC Service

You can manage BDC services using various settings, as Figure 4-3 shows. Let's discuss each of them. Notice that these menu items are contextual, based on the BDC View chosen.

Views

There are three views available, BDC Models, External Systems, and External Content Types, each showing or hiding various options. Let's look at the options each view presents.

BDC Models

Import, Export and Delete

You can import a BDC model definition file or a resource definition file that contains information about connection strings, authentication, and external content types related to the external system, as shown in Figure 4-4. You can also choose to Export a selected BDC Model or delete one or more existing models.

Importing a BDC Model file

Figure 4-4. Importing a BDC Model file

Permissions

Set Object Permissions

You can add users and set permissions to Edit, Execute, Selectable In Clients, or Set Permissions for a particular object in a BDC Metadata Store. An object can be an External Content Type an External System. You can remove user permissions for a selected object if it's not required.

Set Metadata Store Permissions

The BDC Metadata Store includes models, external systems, ECTs, methods, etc. You can assign administrator(s) and set permissions to Edit, Execute, Selectable In Clients, or Set Permissions for the BDC Metadata Store itself. You can remove user permissions for the BDC Metadata Store if not required. If object permissions included in the store need to be overridden, select the option Propagate permissions to all BDC Models, External Systems, and External Content Types in the BDC Metadata Store. Doing so will overwrite existing permissions.

Note

Edit Permission allows users or a group to edit an ECT. Handle this set of permissions very carefully as this has elevated privileges.

Execute Permission allows users or a group to execute CRUD operations. In the case of the metadata store, these permissions are related to metadata store child objects only.

Selectable In Clients allows users or a group to create external lists by choosing an ECT in the ECT item picker.

Set Permissions allows users or a group to set permissions on ECTs or child objects of the metadata store.

Manage

Settings

When an external system contains configurable properties to manage, you can alter them from the Settings menu.

Delete

Choose one or more from the list of available external content types or external systems to delete.

Profile Pages

Configure

Profile pages display data for an item that belongs to an ECT. For instance, it can display all fields of an Employee from the Employees table populated using the ECT. However, profile pages are not automatically created in this version and are available only with SharePoint Server Standard and Enterprise editions. To create a profile page, first you need to enable profile page creation and specify the host site URL.

Create or Upgrade

This setting is also available only with SharePoint Server Standard and Enterprise edition. Once you create a host site and enable profile page creation, you can create a new profile page for a particular ECT, and each ECT will then have a unique profile page or will upgrade existing profile pages from MOSS 2007. Default actions links will be created for these profile pages. For new profile pages, the default action is View Profile. For upgrades, a new action, View Profile (SharePoint 2007), is created. If you re-create a profile page, it overwrites a previous version of the same file.

BDC in MOSS 2007 is part of the enterprise licensing model. However, SharePoint 2010 brings good news for organizations and individuals who have budget restrictions and wouldn't purchase the Enterprise edition but still want to use BCS. SharePoint Foundation 2010[14] comes with some of the BCS features that you can use to connect with external systems.

Figure 4-5 shows the different BCS features available across SharePoint editions. As you can see, SPF has the basic features. To obtain complete BCS functionality, you need the Enterprise edition.

BCS feature comparison

Figure 4-5. BCS feature comparison

This comparison can also be depicted in a feature set view, as shown in Figure 4-6. BCS has an offline capability when connecting with an Office (Office Professional Plus 2010 only) client. However, you can sync data with an external system on a timely basis. For instance, the default sync time for SharePoint workspace with a SharePoint site is 10 minutes. You can, of course, choose to manually sync them at any time.

BCS feature sets

Figure 4-6. BCS feature sets

Let's see at a high level how all these components are connected. As you can see in Figure 4-7, there are three major participants—Business Connectivity Services, External Systems, and Rich Client Office applications. Note, however, that BCS is the connector for the other two layers.

Business Connectivity Services Layer

The BCS layer consists of two major blocks, the BDC Metadata Store and the BCS Client Cache. To understand what the BDC Metadata Store is, you need some background information. The BDC model contains metadata related to external content types, database connections, etc. It actually enables the API of an external system described in the metadata model with a much simplified BDC object model. A metadata model contains real information about methods, entities, and so forth, such as employee data, customer information, and sales orders.

BDC models are stored in SQL Server database tables and are loaded into memory before the BDC runtime[15] can use them. To perform operations such as load, modify, and so on, you make use of stored procedures. All these pieces form the BDC Metadata Store.

BCS High level overview

Figure 4-7. BCS High level overview

The BCS Client Cache essentially copies the external system data from the server and caches it for Office client solutions in the SQL Server Compact Edition database on the basis of per-user instances on the client computer. This facilitates the automatic copying and linking of client data with external systems either manually or by automatic synchronization, thus avoiding heavy transactions between the client and server data and improving the throughput of the application. This caching mechanism also enables offline disconnected mode.

External System Layer

This layer basically consists of the real meat—your data. The external system comprises the LOB system, database, and web service, WCF service, or .NET component. Data from this system is extracted using one of the mechanisms we will discuss later in this chapter, but ultimately is channeled into SharePoint site or Office client application using an ECT. As mentioned earlier, the BCS service and BCS client cache bridge the gap between the SharePoint site and the Office client.

Office Client Layer

The thick Office client application layer contains the client applications, such as Office, SharePoint Workspace, and Word. As discussed earlier, data from the external system is propagated to the client applications using the BCS client cache for automatic or manual sync and data refresh. This automatic cache refresh and synchronization is performed by a process on the client machine called BCSSync.exe, as indicated in Figure 4-8. BCSSync.exe comes as part of Office 2010 installation and is available in %Program Files%Microsoft OfficeOffice14.

BCS synchronization process

Figure 4-8. BCS synchronization process

So far we have discussed a little about terminology, fundamentals, and the core components of BCS. It's also important to see what tools should be used to work with BCS.

Note

The client stack also consists of an additional component called Dispatcher, which will be aware of offline and online modes, is responsible for switching the connection to the external system for synchronization.

Tools Decision Tree

Based on the type of use and implementation, users can be categorized into two groups.

  • Power users or RAD[16] developers who work with out of the box functionalities on both thin and thick clients. These are essentially simple solutions.

  • Advanced developers who work with custom functionalities and design and develop complex applications with both thick and thin clients.

BCS tools are laid out so that each of these groups can take advantage of specific tools to accomplish their missions. For instance, as you can see in Figure 4-9, advanced solutions on the server side can be designed and developed using a custom .NET assembly connector to allow the use of external system data. At the same time, for a basic client solution, you can use Outlook, SharePoint Workspace, or Word.

Tools decision tree

Figure 4-9. Tools decision tree

Now that we've introduced the concepts, let's roll with some examples. But wait; there is one last important concept you need to thoroughly understand in order to proceed.

External Content Types

You learned about ECTs at a very high level earlier. Now, let's take a deep dive. Anything and everything that is accomplished using BDC services is with the help of external content types. You can consider ECTs as the backbone for the entire BCS system. They are the content types that bring the external data sources, along with their schema, access capabilities, and behavior, into thin and thick clients, as shown in Figure 4-10. External content types contain business objects and can be created using either SharePoint Designer or by Visual Studio 2010.

External content types bring external data sources to clients

Figure 4-10. External content types bring external data sources to clients

Once you have ECTs, you can use them in many ways.

  1. Use ECTs as data sources to drive an external list. External lists use metadata defined with the ECT and perform like any other SharePoint list.

  2. Add data from the ECT modeled in BDC to an External Data Column and use the column in any standard SharePoint list.

  3. External lists created using ECTs enable Read / Write operations on external system data, provided the external system allows this.

  4. Display external system data using ECTs using BDC web parts—External Data List, External Data Item, External Data Item Builder, External Data Related List and External Data Connectivity Filter. However, BDC web parts are read-only and can't be used to write data back into external systems.

  5. ECTs supplement profile pages that display ECT item data.

  6. View or edit external system data using view and edit operations through the ECB menu[17] on the external lists.

  7. Use parameterized query and filter capabilities on external lists using ECTs to prefilter the results.

Now you are ready to do a simple exercise. We will do the example first the no-code way, then achieve the same result by writing code.

Note

In this chapter all the examples will use Employee table data from AdventureWorks database. This way, you'll see how different mechanisms can be used with one data source.

Creating Your First ECT Using SharePoint Designer

SharePoint Designer is the no-code mechanism by which you can design a simple ECT to bring external system data into SharePoint for read and write actions. This mechanism is primarily used by power users or RAD developers. By completing this exercise, you'll see how simple it is to build an ECT and how powerful SharePoint Designer is.

On successful creation of the list, when a user attempts to open and view list data, he or she will receive an error "Access denied by Business Data Connectivity." There are two factors to understand here. First, the logged-in user needs to have permission to execute the ECT that created the list. Second, the logged-in user should have permissions on the SQL Server backend to read data from the AdventureWorks database Employee table. Let's see how to configure both of these settings.

Configure External Content Type Permissions

When an ECT is created, it is added to the BDC Metadata Store and can be accessed under BDC Metadata Store views, from which you need to manually configure the permissions related to the ECT. To do this, open Central Administration and from Application Management

Configure External Content Type Permissions
Setting permissions on an External Content Type

Figure 4-17. Setting permissions on an External Content Type

In the Set Object Permission window (Figure 4-18), in the Add an account box, enter a user account or group and click the Add button. In the Permissions section, choose the set of permissions you'd like to assign to the selected user. Choose or leave the value for propagating permissions and click OK.

Setting object permissions to the external content type

Figure 4-18. Setting object permissions to the external content type

Return to your SharePoint site and access the external list you created earlier. You should now see that list populated with Employee table details (Figure 4-19). To edit an item from the ECB menu on the EmployeeID, click on Edit Item. In the Edit Item window, change any value and click on Save, which results in a data update. Similarly, you can perform other operations, such as View Item, Delete Item, as well as create a New Item. Now, why do you have an ECB menu on the EmployeeID column? It's because EmployeeID was chosen as the identifier in this example.

Employee details loaded in an external list

Figure 4-19. Employee details loaded in an external list

Note that in the example, the logged-in user is an Administrator who has the necessary rights on the SQL backend and so was able to view data. However, this will not be the case with every logged-in user. So do you end up giving access to every user of your database? Not a recommended practice.

You will have to set up an unattended service account that has access to the database and will impersonate the logged-in user. Secure Store Service comes to your rescue in such cases. As discussed in previous chapters, SSS replaces single sign-on and allows you configure an unattended service account to avoid authentication issues.

Configure ECT Data Connections with Secure Store Service

In this section, you'll learn how to configure ECT data connections with the Secure Store Service application. The steps are similar to those you performed in Chapter 2. You can either skim through this section or skip it if you want to.

  1. Open Central Administration

    Configure ECT Data Connections with Secure Store Service
  2. In the Target Application Settings window, set the Target Application ID (to BCS-SSS), the Display Name, and the Contact E-mail values. Choose the Target Application Type as "Individual" and the Target Application Page URL as "Use default page", and click Next.

  3. In the Specify credential fields window, leave the defaults and click Next.

  4. In the Members settings, add administrators to the Target Application Administrators list who should have full control on the target applications and click OK.

  5. On returning to the Secure Store Services management window, select the Target Application ID created in the previous steps and click the Set button on the Credentials section of ribbon.

  6. In the Set Credentials for Secure Store Target Application (Individual) window, enter a value for the Credential Owner as well as values for Windows User Name, Windows Password, and confirm Windows Password. Notice that in this case you are setting a domain account, not a SQL Server account. It is important that the user credentials you enter have permissions on SQL Server database tables. Click OK to close the window.

Launch SharePoint Designer and open your SharePoint site. On the Site Objects menu choose External Content Types and select the ECT you created (EmployeesList_From_HR). In the external content type manage settings window, click on either the Edit Connection Properties button on the ribbon in the Connection Properties section, or click on the External System link in the External Content Type Information Section.

In the Connection Properties windows, on the Default tab, choose Impersonate Windows Identity for the Authentication Mode. Enter the previously created Secure Store Service Application ID in the appropriate box as shown in Figure 4-20 and click OK.

Set Secure Store Service Application ID for ECT database connection properties

Figure 4-20. Set Secure Store Service Application ID for ECT database connection properties

When a user with insufficient permissions tries to access the external list, he will be presented with a link to authenticate, as shown in Figure 4-21.

Authenticate with credentials

Figure 4-21. Authenticate with credentials

On clicking the link, the user will be presented with window for entering his credentials (Figure 4-22), and on successful validation, he will have access to the backend system data.

Manage credentials for SSS target application

Figure 4-22. Manage credentials for SSS target application

Now that you have configured ECT with the SSS Application ID, users can access external data via an external list in SharePoint without any issues.

Note

You can't configure an ECT data source with SSS in SharePoint Foundation 2010. You have to use the User's Identity or Impersonated Windows Identity only.

Did you realize that you haven't seen or modified any XML file as you used to do in MOSS 2007? Do you now agree how simple and easy it is to create an ECT in SharePoint 2010? But wait! What if the data source is not a database but is actually a service that is delivering data, and this is the most common scenario your enterprise bus will have? If you use the tools decision tree (refer back to Figure 4-9), you'll see that for advanced solutions, you need to write a custom .NET assembly connector.

Authoring an ECT Using Visual Studio with a .NET Connector

Before you begin actually creating the .NET assembly connector for the ECT using Visual Studio, let's identify the essential steps. Here's what you'll need to do:

  • Create stored procedures that enable the get item, get collection, and set item operations.

  • Author an external content type.

  • Develop a custom .NET Connector and associate the above-mentioned operations to the ECT.

Table 4-1. External Lists vs. Normal SharePoint Lists

External List

Normal / Custom SharePoint List

Requires an external content type to create an external list and holds data related to the external source.

Can use existing content type and holds data related to data within the list.

Can read and write to external data

Can read and write to data within the list.

Can create an external list using SharePoint Designer or a SharePoint site.

Can create a custom list using SharePoint Designer or SharePoint site.

Default views and forms are created to display and edit external data when the external list is created.

Default views and forms are created to display and edit list data when the custom list is created.

Can create custom actions and initiate workflows.

Can create custom actions and initiate workflows.

Can be used with SharePoint workspace or Outlook to display external data.

Can be used with SharePoint workspace or Outlook to display external data.

Customize forms using InfoPath.

Customize forms using InfoPath.

Does not allow management of non-external content types.

Allows management of content types.

Versioning is not supported.

Supports versioning on items.

Can't add additional columns unless the ECT is changed.

Can create columns or use existing site columns

The solution you created earlier using .NET code and deployed to SharePoint in this exercise is deployed globally and will add the BDC model to the BDC Service Application. This means any Web application in the farm can access this ECT, from which you can create an external list. You will see this ECT under SharePoint Designer as a .Net type. We will see how to create an external list from it.

Creating an ECT Using SharePoint Designer and .NET Type

As mentioned earlier, you can also access and use the ECT you created from the .Net assembly. Launch SharePoint Designer and use the Open Site option to open your SharePoint site. From the Site Objects window, click External Content Types. In the External Content Types window, you'll see the list of available ECTs, including the one you created earlier, as shown in Figure 4-32.

External Content Types in SharePoint Designer

Figure 4-32. External Content Types in SharePoint Designer

Click on Entity1 to load the Entity1 external content type. From the Lists & Forms section on the ribbon, click the Create Lists & Form button as shown in Figure 4-33. Also note the operations available with the ECT in the External Content Type Operations section.

Creating an external list from an exisiting ECT using SharePoint Designer

Figure 4-33. Creating an external list from an exisiting ECT using SharePoint Designer

In the Create Lists and Form for window (Figure 4-34), select Create New External List and enter a value for List Name. Leave the other default input values and click OK. If there are more than one model definitions available in the .NET assembly, you can choose one from the System Instance drop-down.

Creating a new external list

Figure 4-34. Creating a new external list

Return to your SharePoint site and find the list with the name (External List Created from SPD ECT) you provided in the previous step. Launch the external list and you'll see this new list with view and edit functionality; it is similar to the lists created using other techniques.

Again, even with Visual Studio and writing a custom .NET assembly connector, you haven't seen or edited any XML file so far, either while creating the model or when defining your entity. This I'd say is one of the biggest advantages when compared with the BDC in MOSS 2007.

Another important improvement of this version over the prior is in the runtime object model. There have been phenomenal changes and more capabilities added in the new version. Let's take a look at them.

BDC Runtime

Recall the question[19] I asked in the Introduction section of this chapter? I'd say the BDC runtime is one of the answers for it. With BDC runtime you now have the ability to represent the external system either using the server-side object model or the client-side. Both server-side and client-side object models are symmetrical; this means that what you can do with the server object model can also be done using the client object model and, in fact, the assembly is the same for both.

Using the BDC runtime, you can not only read but also write back to the external system. There's also a batch-read process by which you can send multiple inputs as a batch and get the corresponding results in a single request and response. This should improve performance and latency phenomenally.

There are many other improvements including streaming support, an extensibility mechanism with .NET assembly connectors, custom connectors, secure store providers, and so on. But what actually compels here is, whenever you develop a custom object using the BDC runtime against an ECT or external system deployed to your farm, it's a one-time deal. As long as the ECT isn't updated, your custom object need not be changed.

What this also means is if your data source changes but your ECTs are untouched, your application will not be affected. Great, isn't it? Let's perform a simple example to understand in more detail.

Integration with Office Applications

You can integrate BCS with Office applications such as Outlook and Word. If you recall the Office client layer (refer back to Figure 4-7), that's what we'll be using now. We will demonstrate a simple example using Office Word; if you'd like to understand how BCS can be integrated with Outlook, we recommend you read Chapter 9 in Sahil Malik's Microsoft SharePoint 2010 Building Solutions for SharePoint 2010 (Apress, 2010).

Integration with Office Word

Launch your SharePoint site and create a document library from Site Actions

Integration with Office Word
Creating an external data column

Figure 4-37. Creating an external data column

Under Additional Column Settings, select the external content type you created earlier in this chapter. Select all fields or only those you wish (Figure 4-38) and click OK.

Choosing fields for the external data column

Figure 4-38. Choosing fields for the external data column

Return to the document library and upload a document by choosing the Add document link and clicking OK. Note that the document can't be empty. Also, before you save the document to the library, select data from External Items icon. Then enter text in the Title textbox and click the Save button as shown in Figure 4-39.

Selecting an external item

Figure 4-39. Selecting an external item

The selected data item is added as an entry to the document library with the columns you chose in previous step. From the document's ECB menu, click Check Out, then click OK in the pop-up window. Click on the document to launch the document in Office Word 2010.

Go to Word

Selecting an external item
Choosing document properties under Quick Parts

Figure 4-40. Choosing document properties under Quick Parts

After you choose the values you're interested in, the final document should look something like the one in Figure 4-41.

Document properties displaying data

Figure 4-41. Document properties displaying data

You can now save the document, check it in, provide any version comments from the Backstage window of the ribbon, and then close the document.

Another important feature of BCS is its integration with SharePoint Workspace 2010. You can work in offline mode and sync back data to SharePoint lists and libraries using SharePoint Workspace.

Integration with SharePoint Workspace

SharePoint Workspace is the next generation of Office 2007 Groove. SharePoint Workspace is a client application that not only enables access to SharePoint Server 2010 and SharePoint Foundation 2010 document libraries and lists, but also can be used in offline mode. We won't cover it in detail here, but you can find more information at http://technet.microsoft.com/en-us/library/ee649102.aspx. Now we'll discuss how to integrate BCS external lists with SharePoint Workspace.

Launch SharePoint Workspace 2010 on your computer. The first time you start Workspace, the Account Configuration Wizard will launch, as shown in Figure 4-42.

SharePoint Workspace Account Configuration Wizard

Figure 4-42. SharePoint Workspace Account Configuration Wizard

You can create a new account using an e-mail address or Account Configuration Code. Once the account is created, the Workspace client will launch. If you have an account file (.grv), you can also restore an existing account using the wizard. From the Workspaces section of the Home tab on the ribbon, select New SharePoint Workspace. In the New SharePoint Workspace window, enter your SharePoint site URL location as shown in Figure 4-43. You can choose and configure a library or list and add others later.

Setting up a new SharePoint Workspace

Figure 4-43. Setting up a new SharePoint Workspace

SharePoint Workspace will begin syncing your SharePoint site lists to your computer. You will be prompted with couple of approval (Figure 4-44) and information (Figure 4-45) screens. After successful completion, click the Open Workspace button.

Verifying the publisher

Figure 4-44. Verifying the publisher

Microsoft Office Customization Installer

Figure 4-45. Microsoft Office Customization Installer

Once the synchronization (Figure 4-46) is successful, Workspace opens and displays the newly connected SharePoint site in the Workspaces list, as shown in Figure 4-47.

Synchronizing the SharePoint Workspace to the computer

Figure 4-46. Synchronizing the SharePoint Workspace to the computer

The new SharePoint Workspace

Figure 4-47. The new SharePoint Workspace

Double-click the name of your server under Workspaces to launch content from all available document libraries and lists (or the selected lists). In the External Lists section, click on the external list you created earlier in this chapter. This will retrieve and display list items as shown in Figure 4-48. If you like, you can choose to disconnect your workspace from the active connection to SharePoint and use the data in offline mode. You can perform all CRUD operations on the list and, when you are ready, you can sync data back to the SharePoint list. If you work in online mode and some changes happen on the server, you will be notified about the update and prompted to refresh the data.

You can search for an item in the list or double-click on a specific row item to edit it. In the Edit Item window (Figure 4-49), you can change values and then click the Save & Close button in the List Item section on the ribbon.

The Workspace window connected to a SharePoint list and data

Figure 4-48. The Workspace window connected to a SharePoint list and data

Editing a list item in Workspace

Figure 4-49. Editing a list item in Workspace

Here is an important factor to keep in mind. In both offline and online mode, if data for one item is changed both locally and externally, there will be a conflict between the local and external system values. The conflict will be displayed as an icon on the row column, and when you open the item, you'll see a Resolve option on the ribbon on the Error Tools menu. To proceed with any changes, you'll have to resolve the conflict by choosing to keep either the external system value or the local value, as shown in Figure 4-50.

Data conflict between local and server versions

Figure 4-50. Data conflict between local and server versions

Note

If you are accessing an external list with a data source that is configured with SSS, Workspace will prompt you to enter SSS credentials.

PowerShell Commands

Now that you've seen how useful the BCS can be, it's time to learn the Windows PowerShell cmd lets you can use to configure it. These commands are shown in Tables 4-2 through 4-8.

Table 4-2. Clear and Copy Operations

Command

Description

Clear-SPSiteSubscriptionBusinessDataCatalogConfig

Command to delete all the data from the BDC Metadata Store for a specific partition or site

Example: Clear-SPSiteSubscriptionBusinessDataCatalogConfig –ServiceContext http://yourservername

Copy-SPBusinessDataCatalogAclToChildren

Command to copy a set of permissions to child objects from the BDC Metadata Store object. You need to create the metadata object first using the Get-SPBusinessDataCatalogMetadataObject command

Example:

$yourmetadataobject = Get-SPBusinessDataCatalogMetadataObject –BdcObjectType "LobSystem" –ServiceContext http://yoursharepointsite –Name"contentdatabase"

Copy-SPBusinessDataCatalogAclToChildren– MetadataObject $<yourmetadataobject>

Table 4-3. Disable and Enable Operations

Command

Description

Disable-SPBusinessDataCatalogEntity

Command to disable an ECT in the BDC Metadata Store. You need to create the metadata object first using the Get-SPBusinessDataCatalogMetadataObject command

Example: Disable-SPBusinessDataCatalogEntity – Identity $<yourmetadataobject>

Enable-SPBusinessDataCatalogEntity

Command to enable an ECT in the BDC Metadata Store. You need to retrieve entity details from metadata object first using the Get-SPBusinessDataCatalogMetadataObject command

Example: Enable-SPBusinessDataCatalogEntity – Identity $<yourentity>

Table 4-4. Export and Import Operations

Command

Description

Export-SPBusinessDataCatalogModel

Command to export a BDC Model. You need to retrieve model details from the metadata object first using the Get-SPBusinessDataCatalogMetadataObject command

Example: Export-SPBusinessDataCatalogModel – Identity $<yourmodel> –Path "<pathfile.dcm>"

Export-SPSiteSubscriptionBusinessDataCatalogConfig

Command to export data from BDC Metadata Store associated with a partition or site

Example: Export-SPSiteSubscriptionBusinessDataCatalogConfig – ServiceContext http://yoursite –Path "pathfile.xml"

Import-SPBusinessDataCatalogDotNetAssembly

Command to import a .NET assembly.

Example: Import-SPBusinessDataCatalogDotNetAssembly – LobSystem $<your db> -Path "filename"

Import-SPBusinessDataCatalogModel

Command to import a BDC model. You need to retrieve Metadata Store details from the metadata object first using the Get-SPBusinessDataCatalogMetadataObject command.

Example: Import-SPBusinessDataCatalogModel – Path "pathfile.bdcm" –Identity $MetadataStore

Import-SPSiteSubscriptionBusinessDataCatalogConfig

Command to import data from an exported file containing all data for the BDC Metadata Store for a given partition or site.

Example: Import-SPSiteSubscriptionBusinessDataCatalogConfig –Path "<filepath>" –ServiceContext http://yoursharepointsite

Table 4-5. Get and Set Operations

Command

Description

Get-SPBusinessDataCatalogMetadataObject

Command to retrieve BDC Metadata Store metadata object.

Example: Get-SPBusinessDataCatalogMetadataObject –BdcObjectType "Model" –Name "yourmodel" –ServiceContexthttp://yoursharepointsite

Get-SPBusinessDataCatalogThrottleConfig

Command to retrieve BDC service application throttling configuration.

Example: Get-SPBusinessDataBCatalogThrottleConfig –Scope Database –ThrottleTypeItems –ServiceAppicationProxy $proxy

Set-SPBusinessDataCatalogMetadataObject

Command to set BDC Metadata Store metadata object property or attribute value. You need to retrieve identity object details from the metadata object first using Get-SPBusinessDataCatalogMetadataObject command.

Example: Set-SPBusinessDataCatalogMetadataObject –Identity $<identityobject> -PropertyName<propertyname> -PropertyValue<value>

Set-SPBusinessDataCatalogServiceApplication

Command to set BDC service application global properties.

Example: Set-SPBusinessDataCatalogServiceApplication –Identity $<serviceapplication> -FailoverDatabaseServer <servername>

Set-SPBusinessDataCatalogThrottleConfig

Command to set BDC application throttling configuration.

Example: Set-SPBusinessDataCatalogThrottleConfig –Maximum <value> -Default <value>

Table 4-6. Grant and Revoke Operations

Command

Description

Grant-SPBusinessDataCatalogMetadataObject

Command to grant permissions to a principal for a specified BDC metadata object. You need to retrieve model details from meta data object first using Get-SPBusinessDataCatalogMetadataObject command and claim details from New-SPClaimObject command.

Example:

$yourclaim = New-SPClaimObject –User "domainusername" –Type windowssamaccountname

$yourmodel = Get-SPBusinessDataCatalogMetadataObject –BdcObjectType "Model" –ServiceContext http://yoursharepointsite –Name "yourmodel"

Grant-SPBusinessDataCatalogMetadataObject –Identity $<yourmodel> –Principal $<yourclaim> –Right <right>

Revoke-SPBusinessDataCatalogMetadataObject

Command to revoke rights for user in BDC Metadata Store metadata object. You need to retrieve model details from the metadata object first using the Get-SPBusinessDataCatalogMetadataObject command and claim details from New-SPClaimObject command.

Example: Revoke-SPBusinessDataCatalogMetadataObject –Identity $<metadataobject> -Principal $<claims> -Right <right>

Table 4-7. New Operations

Command

Description

New-SPBusinessDataCatalogServiceApplication

Command to create a new BDC service application in the farm.

Example: New-SPBusinessDataCatalogServiceApplication –ApplicationPool "<AppPool>" –DatabaseName "<dbname>" –DatabaseServer "<DBServer Name>" –Name "<BDCServiceAppName>"

New-SPBusinessDataCatalogServiceApplicationProxy

Command to create a new BDC service application proxy in the farm.

Example: New-SPBusinessDataCatalogServiceApplicationProxy –Name "proxyname" –ServiceApplication $<serviceapplication>

Table 4-8. Remove Operations

Command

Description

Remove-SPBusinessDataCatalogModel

Command to delete the BDC model. You need to retrieve model details from the metadata object first using Get-SPBusinessDataCatalogMetadataObject command.

Example: Remove-SPBusinessDataCatalogModel –-Identity $yourmodel

Remove-SPSiteSubscriptionBusinessDataCatalogConfig

Command to remove the BDC Metadata Store for a partition or site.

Example: Remove-SPSiteSubscriptionBusinessDataCatalogConfig —-ServiceContext http://yoursharepointsite

Summary

Figure 4-51 highlights what you've learned in this chapter, which includes

  • BCS terminology

  • BCS setup and administration

  • Differences between BCS features across SharePoint editions

  • BCS architecture

  • Authoring ECTs using SharePoint Designer

  • Creating ECTs with Visual Studio

  • Using a .NET assembly connector

  • BDC runtime

  • BDC integration with Office client applications

  • Using PowerShell commands for administration

Business Connectivity Services road map

Figure 4-51. Business Connectivity Services road map

What's Next?

In the next chapter, you will learn about Excel Services, in particular about the improvements in the new version. After an introduction, we will walk you through setting up Excel Services, show you what's new, and show you how to author and publish Excel to SharePoint 2010. You will also learn how to consume Excel Services through SOAP, the REST-based API, and the JavaScript Object Model. Lastly, we will introduce you to PowerPivot and its capabilities.



[10] Line-of-business

[11] CRUD – Create, Read, Update and Delete

[12] You will learn more about External Lists later in this chapter.

[13] A failover server is used in the case of SQL Server database mirroring.

[14] SharePoint Foundation 2010 (SPF) is the new version of WSS 3.0

[15] You will learn more about the BDC runtime later in this chapter.

[16] RAD – Rapid Application Development

[17] ECB stands for Edit Control Button, which is available for items on a SharePoint list or a document library. The ECB menu is often called a context menu, which you can use to perform various operations, such as Edit, View, and Delete.

[18] A Farm Solution is a full-trust solution that provides access to the entire SharePoint API, unrestricted data access, and all solution functionalities. Farm solutions, however, can only be deployed by farm administrators and are unmonitored.

[19] Question - Why use BDC when the functionality can be achieved by writing custom code?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset