Using Word templates in combination with Content Types in SharePoint gives a user a rich experience in using SharePoint metadata in the content of a Word document.
For example: if you are making the meeting minutes for a certain meeting, you would like to have the Meeting Date as meta data of the document, but that same Meeting Date is probably also used in the minutes document itself somewhere.
So we could insert meta data columns as Document Property Quick Parts in the Word document. That way, entering the meta data information in the document information panel, will automatically update the Quick Parts in the document itself as well. If you have never done this before, no worries, I will show you how this works later on.
Now this all works well for SharePoint columns of every type, but lookup columns. Lookup columns have a typical way of storing data. What is you see is not what you get. When you use a lookup column to a SharePoint list, what you see as meta data is the Title field of that SharePoint list, but the value of the lookup column is actually the item ID of the list item you select in your lookup column. So when you insert this lookup column Document Property as a Quick Part in your Word document, not the Title field is shown in your document, but the item ID.
What I will describe in this blog posting is a way to work around this problem.
Let’s take the meeting minutes document as an example again. A typical minutes document could look like this:
Now what we would like as meta data of this document is the subtitle (let’s use the Title field for this), the Meeting Date, and the associated Project the meeting was held for. So let’s create a Content Type called Meeting Minutes as the screenshot below:
What you can see already, is two columns for the Project meta data. This is necessary for my work around to work, as you’ll see later on.
Under Advanced settings, upload your Word template for your meeting minutes.
Now we will create a custom Document Information Panel in InfoPath. Click Document Information Panel settings. Click Create a new custom template.
This will fire up InfoPath. InfoPath will first tell you that it will create a form template for your custom content type, and you need to publish the template if you’d like to use it. Duh! Click Finish. And there you have your Document Information Panel.
What we need to do, is have the Project field automatically updated when you choose a project from the Project Lookup. Do this as following: Double click the Project text box. In the Text Box Properties window, click the fx button next to Value. Click Insert Field or Group…. In the Data source drop down, select the data source starting with list_, and select the Title dataField.
We need to filter the Title value. Click Filter Data… and next Add… In the first drop down select ID, then is equal to, then select a field or group… Now choose the Main data source and select the Project dataField.
Click a few times OK, until all windows are closed, and you’re back at your InfoPath form.
Before you close the last window, you could also decide to make the Project field read-only:
Save your InfoPath form (File –> Save as), and then publish it (File –> Publish), Next, Publish, Close.
Now we are going to add the meta data as Quick Parts in your Word template. Attach the new Content Type to a Document Library of your choice and start a new Word document from this Content Type.
On the Insert ribbon, click Quick Parts, then Document Property, and then insert the properties you like on the places in your document of your likings. The document will look like this:
Be sure to insert the Project property and not the Project Lookup property. If you insert the Project Lookup property, you will see the ID of the project will be inserted in your Word document, instead of the name of the project.
Finally, save this document and re-upload it as the template in your Content Type.
Now you have a SharePoint Content Type with a Word template attached, where Word content and meta data are in sync.