blog.dennus.net A reflection on Microsoft Office SharePoint Server 2007 (and other stuff…)

19Nov/090

SP2010 – Quick writeup about list referential integrity

There's a new and much requested feature in SP2010 and that's referential integrity on (custom) lists. This blog post is a quick writeup of that new feature just to document what I've found so far. Hopefully it's helpful for someone else as well.

Right, we have our SharePoint site which contains two custom lists:

- ParentList
- ChildList

ParentList has the following columns: Id, Title, Name, Address and City
ChildList has the following columns: Id, Title

We're going to use a lookup column to relate the two lists together, just like it works in SharePoint 2007.

Parent List with some sample data

Parent List with some sample data

The screenshot above shows the parent list, including some sample data we're going to display in our child list. First, we're going to add the lookup column to the client list, so we can relate the two lists.

Child List - New Lookup column

Child List - New Lookup column

Nothing new here :)

Lookup Column Additional Info

Lookup Column Additional Info

The thing that's new here, if I recall correctly, is that you can now select multiple columns from the parent last that you want to include in the child list. I've selected to display the Title, Name, Address and City of the parent list, as you can see in the screenshot. The screenshot shows a relationship on ParentList:ID, but I've changed that to Title in my own setup.

The new feature is depicted in the screenshot below. This feature allows you to specify whether you want to enforce a relationship on this data and what kind of action should be taken when an item in the parent list is deleted. In our example I'm going to restrict the deletion, which I'll demonstrate later. You could select cascade delete, and the item in the child list will be deleted upon deletion of the parent item, just like in a relational database. 

Lookup Column Relationship

Lookup Column Relationship

However, when you try to add the column, SharePoint will likely come up with an alert, saying that the parent column needs to be indexed before the relationship can be enforced.

Lookup column index

Lookup column index

Just click OK here, to index the column. So, now that we've added the lookup column, the additional columns we've selected, are also displayed in the child list, like this:

Client list after adding the lookup column

Client list after adding the lookup column

You can see here that the additional columns have been added in a format of <lookup column name>:<parent column name>, so this allows for easy distinction between columns that are coming from the parent list and the ones that exist on the child list.

Adding a new item will result in the following form:

New client item

New client item

 
As you can see here, you can select the parent item, which is nothing new obviously. The client list will look like this once the item has been added.

Client list - item added

Client list - item added

So, there you see the info that comes from the parent list. Now, let's try to delete the linked item in the parent list to see what will happen.

Delete parent item

Delete parent item

As expected, you will get an error message, indicating that you can't delete the item because of a relationship constraint between the items. The error could have been a bit more user friendly I suppose, but I've learned to expect stuff like this from SharePoint :)

Parent list item delete error

Parent list item delete error

So, there you go, some quick information about relational integrity in SharePoint 2010. I think this should help us all utilize custom lists for scenarios where you'd rather use a database. Obviously, using a regular database brings a lot more advantages, but it's really nice to have this functionality in SharePoint now, without having to code your own event receivers and stuff. :)

Filed under: SP2010 No Comments
18Nov/090

SP2010 – Now possible to change your page layout on the fly?

Wow, this seems like an interesting and much requested feature I just discovered in SharePoint 2010. It seems you can now change the page layout of an existing page! Maybe this is old news already, but I hadn't heard anything about it yet.

So we have our regular article page right here:

SP2010 Article Page

SP2010 Article Page

When you expand the Page Layout button on the ribbon, you get this:  

SP2010 Change Page Layout

SP2010 Change Page Layout

 Let's for example select Blank Web Part page as the new layout for our page. SharePoint then takes the new setting, doesn't perform a post-back anymore, AJAX is very nicely integrated now:

SP2010 - Changing Page Layout

SP2010 - Changing Page Layout

When SharePoint is done processing the changes, our page is now a web part page instead of the article page it was before!

SP2010 - Web Part Page
SP2010 - Web Part Page

 
Edit:

The functionality isn't completely bug-free yet. After playing around with a couple of different page layouts, I'm suddenly getting this error:

SP2010 Change Page Layout Error
SP2010 Change Page Layout Error

Obviously the product is still in beta, I'm sure this will be fixed in the final version :)

Filed under: Uncategorized No Comments
18Nov/098

SP2010 – SPUserCodeV4 – Your new web part project isn’t deploying?

So you've just gone through all the trouble to get the new SharePoint 2010 beta installed with the new Visual Studio 2010 beta alongside of it. You've created your first web part project and you're ready to deploy!

Only one minor issue though, when you try to deploy, you're getting an error, saying that "Cannot start service SPUserCodeV4 on computer <computername>".

Visual Studio 2010 - SharePoint project deployment error

Visual Studio 2010 - SharePoint project deployment error

Although the screenshot shows an error with retracting, I was getting the same error when deploying. I figured, maybe it works if I deploy it again, but alas :)

The error is related to a service not being started on the SharePoint server. In order to start it, do the following:

- Go to Central Administration -> System Settings -> Manage services on server
- Locate the service "Microsoft SharePoint Foundation User Code Service"

SP2010 User Code Service

SP2010 User Code Service

On my server it wasn't started by default. I'm not sure if something went wrong during installation and that this service should be enabled by default. Just click the "Start" link button to start the service.

Now go back to Visual Studio 2010 and retry deploying your solution. In my case, this did the trick; the project was deployed successfully deployed!

VS2010 Sharepoint Project Deployed

VS2010 Sharepoint Project Deployed

 
Thinking about it, it might have something to do with the order of installation. I installed Visual Studio 2010 after I installed and configured SharePoint 2010. Maybe for some reason SharePoint only picks this up when it can find a Visual Studio installation or something like that. Not too bothered to find out though, the installation took a few precious hours and I don't really feel like doing all that again :)

Filed under: Uncategorized 8 Comments
17Nov/090

Making a custom Outlook ribbon group appear in another inspector – bugged?

For a small assignment for a client, I've created this custom ribbon for Outlook, which holds a new group with a couple of custom controls relevant for a new mail message. They'd like to add a couple of extra MIME headers if any of the recipients is outside their domain. So far, this was relatively easy to do (still, I find the documentation about Outlook and VSTO a bit scarce, required quite the amount of Googling). However, since meeting requests can also have external recipients, the custom ribbon group should appear there as well.

Luckily, I found a blog post on a very good blog which explains how to do this. The post can be found here.

So, I've followed the instructions there, created an event handler for the New Inspector event and built in a check to see if the new item is an meeting item. If so, set the OfficeId to "NewAppointment".

This generally seems to work, except when you open new items in a specific order. Then all of a sudden the custom group doesn't show up in the new meeting form anymore.

Following these steps seems to work just fine:

  • Debug the application
  • Compose a new meeting (the custom group appears)
  • Compose a new mail message (the custom group appears)
  • Compose a new meeting item again (the custom group appears)

However, when I change the steps to the following, the custom group doesn't appear anymore in a new meeting:

  • Debug the application
  • Compose a new mail message (the custom group appears)
  • Compose a new meeting item (now all of a sudden the group doesn't show up anymore!)

I can't really find out why it doesn't work. When adding a breakpoint to the Load event of the Ribbon, I did found out that for some reason the Load event doesn't fire anymore for a meeting in scenario #2. It works just fine if I follow the procedure in scenario #1 however.

The way I've currently solved it is by creating a duplicate of the ribbon and setting the OfficeId to "NewAppointment". Obviously, this doesn't deserve any prizes for elegance, but for now it does the trick...

I'll be sure to write an update to this post should I find out how to deal with this weird issue.

Filed under: VSTO No Comments