Friday 27 April 2012

Mastering Business Connectivity Services in SharePoint 2010 (Part 1)

They call me the “Connector guy”- affectionately of course- where I work, because I am like a Business Connectivity Services (BCS) machine when it comes to crunching out connectors to legacy systems. So I thought I would take the time to help others get over the learning curve of leaning to use BCS.
After reading this article, I hope you will agree that creating External list to data is just a walk in the park-like most tasks developers do, when they get the hang of it. The following chart is a good reference and depicts nicely that many tasks can be performed using the BCS architecture. In fact, almost any tasks can be performed using simple lists exposed by Business Connectivity Services (BCS) Services. In fact, “Everything is a list”, is one of my popular sayings.

BCS Architecture

BCS SharePoint 2010 Architecture
So if everything is a list, then let’s get started building some lists!
Note: I am going to assume that you have a development environment set up- probably on a virtual machine, and that you have an instance of SharePoint 2010 on that machine. Microsoft has simplified the development process greatly, but requires a lot of software installed as a prerequisite to getting started with SharePoint development. Ah, the pains of being a Microsoft developer!
Anyway, fire up VS 2010 and select File, New, and Project from the file menu. Again, Microsoft has done a nice job of creating templates for a lot of the SharePoint objects required to be successful in this environment- and yes, there is a BCS Template:
Business Data Connectivity Model
After selecting Business Data Connectivity Model from the SharePoint 2010 list and naming the project whatever you want, you will and up with the good, start towards creating a connector that will be exposed as a list on your SharePoint site:
SharePoint Connector
I know what you’re thinking. This looks like any other template, with very little functionality and a lot of work to get it in shape to work in a real-world environment. Am I right? Well, your thinking is correct, but that is the reason I am writing this article. I thought the same thing, and as it turns out there a lot of little nuances in creating a “good connector”, and I will show the best way that I have found- and you can modify my model to fit your style.
Note: I think you will find using BCS, that taking small steps is going to prove to be a better strategy then plowing through all the steps and getting to the end, only to have a connector that is throwing errors and not being able to figure out how to fix them-(The correlation id problem- more on that later.)
So here is the first small step: Let’s rebuild the solution and deploy it to SharePoint - we will find out many things from this simple task:
1. Will the project compile without error?
2. Will it deploy to SharePoint?
3. Can we set the appropriate security settings on our BCS Component?
4. Can we create an External list in SharePoint using this BCS Component?
If all the steps go well and run without error, then we will be able to begin creating custom BCS components. The steps are as follows
Step 1 - Rebuild the solution
Step 2 - Deploy the solution
Step 3 - Set the permissions
Step 4 - Create External List in SharePoint 2010
Step 5 - Preview the list
Let us explore these steps in details:
Step 1: Rebuild the Solution
Select build rebuild solution from the File menu
Step 2: Deploy the Solution
Select build deploy from the File menu
Step 3: Set the permissions
Open SharePoint Central Administration (http://yoursite:8080) in most cases
Click on application management > manage service applications > Business Data Connectivity Service and find Entity1 from the list- this is the entity that we just deployed
SharePoint BCS Model Permission
Click on Entity1 and you should see this screen:
SharePoint BDC Object
Click on set object permissions and give the appropriate rights to those who will be viewing the list
Step 4: Create the external list
Go to the main SharePoint site (http://yoursite) and click on site actions > view all site content > create, external list > create
Sharepoint External List
Click the second icon from the External Content Type and select Entity1 from the pop-up:
Sharepoint External Content Type
Select create and your list will be created
Step 5: Preview the list
Preview Sharepoint BCS List

Summary

Congratulation, you’re on your way to becoming the “connector guy/girl” at your company. Of course this connector doesn’t do much, but we have fulfilled all the steps required to our ultimate goal of making “everything is a list”. If you have gotten this far, and you are looking at the list we created above, then all the obstacles have been cleared to creating your own, more powerful connectors!

No comments:

Post a Comment