SharePoint – Adding the document-version-history into MS Word

Office has a lot of nice features connected to SharePoint, one of them should be a way to insert the version history into your document. Unfortunately there’s no such thing. Maybe because MS wants you use SharePoint when you check the version history. But documents can be taken offline, moved, mailed or whatever and the person reading the document doesn’t necessary have access to SharePoint but still wants to know the story behind the document.

There is no fancy way to do this, not without an Office-Addin and nobody wants that, considering development hours and distribution to clients.

I had to figure out a way to get the document-version-history from SharePoint 2010 into MS Word using SharePoint/Office functionality. This is nothing standard and from what I have found, there is no easy way to do this.

What if I could use a Quick Part to show this? And since fields from SharePoint can be shown as Quick Parts in MS Word, this might be an easy way to do it!?

First I created a hidden field with PowerShell, a Note field with unlimited length and added it to the Content Types used by the documents. You can of course create a feature, console application or likewise to do this.

Do not use $field.Hidden = $true, this will cause the field to NOT appear as a Quick Part.

When this is done, you will have a field that will not be shown in SharePoint forms, but it will appear as a Quick Part in MS Word.

(more…)

SharePoint – Adding the built-in Document-ID in the document file name

I discovered that this has been done many times after we did it. Anyway, I will share my experience.

Back in 2010 I was involved in a project which consisted of creating a strict SharePoint site with meta-data oriented document storage. No folders what so ever, except for 10 document libraries. This idea wasn’t that hard to implement considering how easy it is to create static metadata in SharePoint and adding it to Content Types. How ever, if you want to put all documents in the same container, you will have to use unique file-names, otherwise files with same names will overwrite each other with new versions.

Now, how do you create a unique file name that i based on the file name which the user has entered? Well, you can always just add a custom ID or the list-item-ID in the end of the file name or you can use folders like normal people and pray that no one uploads a document with identical name.

In this case we had already decided to use SharePoint 2010’s built-in feature for generating Document-ID. By using this we will also be able to use some other features that is connected to the Document-ID, like search and the ability to create dynamic URLs (which i will get back to).

One of the requirements was that the user should never have to see their document in SharePoint without the unique ID in the file name.

(more…)