Archive for July, 2009

SharePoint BDC Part 2: Creating your first BDC Web Part

July 25th, 2009 by Tobias Zimmergren

Author: Tobias Zimmergren
URL: | | @zimmergren


In my previous article (SharePoint BDC Part 1: Getting started with the Business Data Catalog) I talked about what you’ll need to do in order to begin to work with the BCD in SharePoint (MOSS 2007 specifically, as it’s an Enterprise feature).

In this article I will briefly guide you through the process of creating your first BDC Web Part that will communicate with the BDC.

Note: You can download the source code for this sample project here [Download]


You need to have your BDC set up and ready to use before you can start creating your own BDC Web Parts to communicate with the BDC. (See my previous article for a walkthrough)

We will also use Microsoft Visual Studio (2005/2008) to create the Web Part.


What we had -> where we’re going

In the previous article I talked about using the built-in Web Parts for your BDC needs. Although they fill a lot of requirements, sometimes you just might want to write your custom Web parts instead.

This is what the standard BDC list looks like:


This is what the final result will look like: (Note, this is a custom Web Part which you’ll develop in the following steps)

Step 1 – Create a new Web Part project

I will expect that you already know how to create a new Web Part project (either using the VSeWSS or using WSPBuilder, or any other tool of preference).

See this article for a WSPBuilder complete walkthrough: WSPBuilder – Walkthrough of the Visual Studio Add-in

Step 2 – Add the BDC references to your project

Once you’ve got a Web Part project up and running, you should add some references that are needed for the BDC Object Model.

You should add the "Microsoft® Office SharePoint® Server component" reference to your project:

Once you’ve added this reference to your project, you have a GO for using the BDC namespaces.

Add the following using-statements to the top of your Web Part:

using Microsoft.Office.Server.ApplicationRegistry.MetadataModel;
using Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db;
using Microsoft.Office.Server.ApplicationRegistry.Runtime; (if you need it..)

This is what my Visual Studio project looks like when using the WSPBuilder to create my Web Parts (notice the reference to microsoft.sharepoint.portal which comes from the reference we added):

Now we’re good to go! Let’s start coding then!

Step 3 – Utilize the BDC object model to access data

Note, you can download the complete Visual Studio Project at the end of this article with the source code.

Fetches all the LOB instances from the metadata repo:

var myInstances = ApplicationRegistry.GetLobSystemInstances();


Fetch the HR instance for Human Resources:

var humanRecourcesInstance = myInstances["HR"];


Pick out the Department entity from the HR instance:

var departmentEntity = humanRecourcesInstance.GetEntities()["Department"];


Fetches the method GetDepartments which is specified in our ADF file (Application Definition File) for our BDC connection:

var getDepartmentMethod = departmentEntity.GetMethods()["GetDepartments"];


Fetches the MethodInstance DepartmentFinderInstance:

var deptFinderInstance =


We call the departmentEntity.Execute() method to fetch DbEntityInstance’s:

var foundEntities = 


Simply loop the DbInstances and then shoot out their name in a bunch of literal controls.
In a real scenario, we would most likely add those intances to an SPGridView instead of printing Literals to enable Views, Sorting, Paging and a whole set of awesome features that comes with the Grid View.:

while (foundEntities.MoveNext())
    var currentDepartment = (DbEntityInstance)foundEntities.Current;
    Controls.Add(new Literal{Text =
              "<div style=’border-bottom:1px dashed #c0c0c0; width:100%;’>"});

    Controls.Add(new Literal {Text =
              currentDepartment.GetFormatted("Name")+ "<br/>"}); 

    Controls.Add(new Literal { Text=
currentDepartment.GetFormatted("DepartmentID").ToString() }); 

    Controls.Add(new Literal{ Text = "</div>" });

When you’ve written the aforementioned code, you will have the base set up for retreiving data from your BDC connection. You will (of course) have to dig a whole lot deeper if you want to master the arts of BDC and the object model that comes with that. But at least it’s a start for you to get to know the namespace, and learn what namespaces to use – and see that it actually works!

Step 4 – Finalize and deploy your Web Part

Once you’ve created the project, build it and deploy to your SharePoint development machine and add your Web part to see the action:

(Yes, the Web Part is called SharePointRules BDC Web Part – and for a good reason too!)

Step 5 – May your creation shine upon SharePoint! (aka. Final result)

This is what the creation looks like (wow..), which basically only utilize the most basic aspects of the BDC Object Model to get started – but here you have it in action, fetching data immediately from your back-end SQL server (Adventure Works database in this case) using the BDC:



That’s a wrap for this article. I have walked you through the few simple steps needed to create your own first BDC Web Part.

In my next BDC article I will talk about what alternative tools I find suitable to use for generating your ADF (Application Definition File).


Free Bamboo Solutions products for User Groups

July 23rd, 2009 by Tobias Zimmergren

Author: Tobias Zimmergren
URL: |


Recently I’ve been having discussions with Bamboo Solutions regarding using their software on our new Sweden SharePoint User Group / Sweden SharePoint Community site which is going to be based on WSS 3.0.

This week I received the good news that Bamboo is now offering all User Groups the possibility to use their products for free on their community sites.

Read more about their announcement here:

This is great news for the Swedish SharePoint User Group / – Time to rock’n'roll!

Have fun!

SharePint in Las Vegas

July 22nd, 2009 by Tobias Zimmergren

Author: Tobias Zimmergren
URL: | | @zimmergren

SharePint is planned for Vegas

For any and all of you who are going to Vegas for the SharePoint Conference (SPC), I’ll be glad to forward the message from AC – there’s going to be a huge SharePint.

Read more about it here, and if you’re planning on attending – leave a comment in AC’s blog about it!


Twenty (20) Rich Text Editors to use in your applications

July 14th, 2009 by Tobias Zimmergren

Author: Tobias Zimmergren 
URL: |


Lately I’ve been looking around for some decent rich text editors for use in my (and SharePoint) applications.

I found this awesome article explaining 20 free rich text editors you can use, some better than others:

My favorite ones

As for which ones I would call my favorite (based on functionality, compatibility, performance and ease of deployment) – I would have to say:

Just be sure to read the license for each of the different editors. Some are GPL/LGPL, others are completely unlicensed and some uses other licensing models.

Have fun :-)

Just like the previous posts, this is just going to be a short "heads up" on some new documentation and links that just showed up on the Microsoft Download Center site:

2010: Microsoft SharePoint Products and Technologies Protocol Documentation

2010: SharePoint Products and Technologies: 2010 (Technical Preview) Developer Documentation


SharePoint 2010 Sneak-Peak videos are officially out

July 14th, 2009 by Tobias Zimmergren

So, if you haven’t heard it already, has updated some information and now let us in on some details about SharePoint 2010.

Take a look at the preview/sneak-peak videos and be amazed! I’m stunned. Wow!

You’ll find the videos here:

Have fun :-)

Author: Tobias Zimmergren 
URL: http://www.zimmergren |


Sometimes the only option you’ve got is to alter things using the object model of SharePoint. In this particular case I wanted to change the RSS-settings for a specific list.

So that’s what this little tip is about – customizing the RSS settings of any SPList object using the SharePoint API.


Today I wanted to change and/or customize the RSS settings for a specific list that exist on my site though the API. I found that this wasn’t as obvious as you’d like it to be, and hence I’m writing it down.

The SPList object has a .EnableSyndication property which you can use to turn on RSS for the list, but there’s no obvious property to access if you want to change the RSS settings itself.

Get it working

On your SPList objects, you’ve got the RootFolder property that contains a collection called "Properties" in which you’ll find all sorts of useful information for the list itself.

In my case I wanted to fetch all the settings related to RSS, and made a simple console application to iterate the items in the Properties collection and ended up with the following:










This is the code  to list the properties:


Alrighty, so we have the code to see the properties (or use the SharePoint Manager tool from CodePlex). Now we want to alter those properties. Simple:



In order to accomplish the simple task of reading, changing or setting the properties in regards to RSS settings for your list (or any other property, for that matter) – all you need to do is utilize the RootFolder.Properties collection and access the vti_rss_ properties:


I’d like to shout out a thanks to Andrew Burns for being quick on twitter and pulling an answer out of his sleeve for this.