Insert SharePoint version number in a word document
Inserting the SharePoint version number in a word document was never a straight forward undertaking. Unlike other document properties, which can be directly accessed via Quick Parts, the version number is hidden from the user. Using the workaround described in this post, though, power users were capable to accomplish the task without coding. In the future this method will no longer be an option:
“The label policy feature has been deprecated and should not be used in SharePoint Server 2013.”
Therefore, another solution needs to be found. In this blog post we will describe how the version number can be inserted using an OOTB SharePoint Designer Workflow. However, we will also point out the drawbacks of this approach and further provide a brief evaluation of alternatives.
First of all, we need to create a new column and name it something like “DocumentVersion”.
Set the type to “Single line of text”.
Open your site in SharePoint Designer and create a list workflow for the document library, where your word documents are being stored. We are naming our workflow “Copy Version Number”.
Insert the action “Update list item”.
Click on “Add”.
Select the column created in the first step.
In the below field click on “fx”.
Set the Data source to “Current item” and then select ”Version”. Save every window by clicking “OK”.
Optionally you can insert log messages to track steps in the workflow history. In this case we insert a log message, when the item was updated successfully.
In the workflow settings check the boxes for “Start workflow automatically when an item is created” and “Start workflow automatically when an item is changed”.
Finally publish the workflow.
Add a Microsoft Word file to your document library. The workflow automatically runs and enters the Version number into your column. However, here you can already see one of the drawbacks of this approach. Due to the workflow updating a field, the version number is increased as well. This becomes an even bigger problem, when documents need to be published in major versions. The workflow would always create a minor version on top.
Open the word document and click on “Insert” in the ribbon. Click on “Quick Parts”.
Select “Document Property” and then your column.
The document version has now been placed inside the word file.
Each time we edit the file and save it, our workflow will be initiated.
Beware that it could take up to 10 minutes until the item is updated. This is due to the SharePoint Services putting a write lock on your document. https://support.microsoft.com/en-us/kb/899709
There are several approaches to insert the version number into MS Word, each having its own pros and cons. We will briefly review each option.
Option 1: OOTB SharePoint Designer Workflow
A SharePoint Designer Workflow copies the version number into a metadata column, which is then inserted via Quick Parts into MS Word.
Pro: No coding is necessary. This solution can be implemented on client-side.
Contra: The Workflow itself increases the version number every time it runs. It can take up to 10 minutes until the item is updated.
Option 2: Event Receiver
An event receiver is utilized to copy the version number into a metadata column, which is then inserted via Quick Parts into MS Word.
Pro: In contrast to the workflow approach, the event receiver does not increase the version number, when updating the column.
Contra: This solution needs to be programmed. Also, a server-side installation is required.
Option 3: Custom field type
A custom field type is developed, which keeps track of the version number independently from the SharePoint version.
Pro: You can implement your own versioning logic.
Contra: The programming of this solution is even more complex than Option 2. Also, a server-side installation is required.
Option 4: Manual versioning
There is always the option to manually write a version number in the word document. Although, this solution might appear surprisingly bland, it is yet the most intuitive way from a user perspective. The author has complete control over the version number and does not have to configure or program anything in the background.
Pro: Version can be chosen deliberately. Easy for users to understand. No configuration or development required.
Contra: It is a manual task after all.
With the deprecation of the labeling feature and Microsoft not providing an OOTB solution instead, users are only left with inconvenient workarounds. If you do not want to resort to manually updating the version, you can implement a workflow. However, this will result in a slightly distorted versioning. Every other automated solution relies to a certain amount on programming skills.