Archive for April, 2010

SharePoint Evolution Conference, London

April 22nd, 2010 by Tobias Zimmergren

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

As many of you guys out there know already, the conference called SharePoint Evolution Conference just came to an end yesterday.

SPEvo was a 3-day conference with lots and lots of great sessions and superb entertainment. Just around the corner of the Big Ben, the conference was very centrally located for everyone’s convenience.

Follow up with the SharePoint Evolution Conference

If you attended the conference, you’ve been getting a great deal of sessions delivered to you up front. But if you didn’t make it to the conference, there’s a few alternatives to catch up with some of what was presented.

  • Twitter
    • Make a search for #SPEvo which is the tag used for tweets about the conference
  • Blogs
    • Make sure you follow the speakers blogs and take advantage of their presentations being published there to follow along yourself.
  • User Groups
    • If you are not a member of a user group in your local area – get going immediately, as this is a one-stop-shop for getting hot and new information on SharePoint.

Highlights

Below are some of my snapshots taken with my phone. Of course there’s a great bunch of pictures from the entire conference, and I would urge you to check out Matt’s blog as he has posted some great pictures following the conference here

SPEVo (12)

SPEVo (8) 

SPEVo (10)
SPEVo (15) SPEVo (23)

SharePoint 2010 – The Developer Tour (Sweden)

April 15th, 2010 by Tobias Zimmergren

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

We’re not too far from a release of the awesome Office and SharePoint products in the 2010-family, and as we approach this release we’re preparing some fantastic stuff for all of you developers to indulge in order to be somewhat prepared when it hits the market.

These events will be presented by André Henriksson and some Microsoft partners. I will be helping out with this presentation in Malmö and my mate Wictor Wilén (Who recently became a SharePoint MVP) is going to be helping out in Stockholm.

To read more about the agenda, keep an eye out in André Henrikssons blog:
http://blogs.msdn.com/ahenrik

When, Where and Signup?

I’ll be presenting during the Malmö-event, which you can find here:

Malmö, May 10th: Click here

In addition to the Malmö-event, there will of course be a few more stops of this tour along the way with different speakers and presenters:

Sundsvall, May 5th: Click here
Stockholm, May 17th: Click here
Umeå, May 19th: Click here
Göteborg, May 25th: Click here

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

In this article I will talk about how you can create your custom Document ID provider for your SharePoint Server 2010 installation. Sometimes I’ve been getting the question weather or not it’s possible to change the behavior or change the way the Document ID’s are generated, and some people have a tendency to say no to that question, just because there’s no interface or out of the box functionality to do so.

I’ll give you a quick walkthrough of how you can extend your Site Collection by adding a custom Document ID provider, that will automatically generate custom ID’s based  on your own algorithms entirely!

Recommended reading about Document ID’s before proceeding: 
http://msdn.microsoft.com/en-us/library/ee559302(office.14).aspx

Document ID overview

This section will give you a very brief conceptual overview of Document ID’s in SharePoint Server 2010.

What is Document ID’s?

Document ID’s in SharePoint Server 2010 provide you with the ability to tag documents with a unique identification number. Something a lot of my clients have done manually or by implementing custom solutions to take care of in SharePoint 2007. With this new feature, you get all the required functionality to tag documents with unique identification numbers based on a specific pre-set formula with a custom prefix.

See this sample screenshot for an example:
image

Where do I enable Document ID’s for my Site Collection?

In order to enable Document ID’s in your Site Collection, you’ll need to activate the Site Collection Feature called Document ID Service.

See this screenshot for an example:
image

How do I change the way my Document ID’s are generated?

If you want to alter the way the Document ID’s are generated for your documents in your Site Collection, you can do that by navigating to:

Site Actions – Site Settings – Document ID Settings, like so:
image

From this new settings page, you’ll get the possibility to tell SharePoint how it should generate your unique ID’s. You can specify a prefix for all the generated ID’s:
image

I want to take it one step further!

If you’re not quite satisfied with the way SharePoint 2010 generates your Document ID’s for you, then you should most definitely follow along with the rest of this article as I will guide you through the steps to create your very own Document ID provider to generate exactly the kind of ID’s you want – based on your very own code/algorithms!

Bring it on!

Learning about a SharePoint 2010 Custom Document ID provider

This section will give you an overview of what you will need in order to create a custom Document ID provider for SharePoint Server 2010!

Note: As of this writing MSDN isn’t fully updated on these new SharePoint Server namespaces. Some details may or may not change when SharePoint Server 2010 is released into the wild (RTM)

Microsoft.Office.DocumentManagement

The namespace Microsoft.Office.DocumentManagement contains a class called DocumentIdProvider, which will be the base for our upcoming project!

Microsoft.Office.DocumentManagement.DocumentIdProvider

This is the class we will derive from when creating our custom provider. It contains three (3) abstract methods and one (1) abstract method that we need to implement:

A description of each of these methods and the property will be made inline in my code in the samples!

Creating a SharePoint Server 2010 Custom Document ID provider

Let’s code this little piece of functionality, shall we. The final project (very basic) will look something like this:
image

So, let’s get coding.

1. Create a class and derive from DocumentIdProvider

public class CustomDocumentIdProvider :
Microsoft.Office.DocumentManagement.DocumentIdProvider
    {
        // Method to generate the actual document ID. Awesomeness lives here!
        public override string GenerateDocumentId(SPListItem listItem)
        {
            // In this method we will tell SharePoint how it should generate
            // the unique ID we want.
            // In my case, I’ve just created a dummy-generator. 
            // Normally you would perhaps want to fetch this from another system or
            // generate it properly instead of like this.. 

            // Points to a method I’ve created that generates foo-ID’s
            return FooSampleIDGenerator.GetFooUniqueID();
        } 

        public override bool DoCustomSearchBeforeDefaultSearch
        {
            // If set to true: It will call the GetDocumentUrlsById method before search
            // If set to false: It will use SharePoint Search before custom methods
            get { return false; }
        } 

        public override string[] GetDocumentUrlsById(SPSite site, string documentId)
        {
            // Returns an array of URLs pointing to 
            // documents with a specified DocumentId
            // An empty string array 

            // This is where you will implement your logic to find
            // documents based on a documentId if you don’t want to use
            // the search-approach.
            return new string[] { };
        } 

        public override string GetSampleDocumentIdText(SPSite site)
        {
            // Returns the default Document ID value that will be initially
            // displayed in the Document ID search web part as a help when searching
            // for documents based on ID’s.
            // This should correspond with the way you’ve designed your ID pattern
            return "AWESOME-12345-67890-SharePointRules";
        }
    }

2. Create a Feature Receiver to hook up your custom provider with your Site Collection

public class ProvisionCustomDocIdProviderEventReceiver : SPFeatureReceiver
{
    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        DocumentId.SetProvider(properties.Feature.Parent as SPSite,
                                                                 new CustomDocumentIdProvider());
    }
    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        DocumentId.SetDefaultProvider(properties.Feature.Parent as SPSite);
    }
}

Actually, you’re all done with the code for now.

3. Go to Document ID Settings page and see this message appear

image

This basically means that your custom provider has been successfully enabled (as per our Feature Receiver).

4. See that the Document ID’s on your documents now is using your custom provider

(Please allow for some time to pass so the Timer Jobs can do their magic, or manually go into Central Admin and run the timer jobs instantaneously)

Behold, awesome custom Document ID provider in action:
image 

Summary and Download

What did we just do?

What we just did was to create a custom Document ID provider that generates our very own custom Document ID’s based on whatever algorithm or pattern we want. There’s no need to follow the built-in format for your generated IDs – which some people have presented in their seminars and blogs. So there you go, step by step!

This could be especially awesome if you’ve got an external system generating Document ID’s already, and you want SharePoint to use those ID’s alongside whatever other system is running. Use your own imagination as to what can be done. The code is in your hands, Obi Wan Coder!

Download project

You can download my sample project here

Enjoy, and please don’t be afraid to leave comments!