Wednesday, June 29, 2016

Show Created date from Sharepoint document library via Word Quick parts

In Word it is possible to add Sharepoint metadata fields directly to the document: Insert > Quick parts > Document properties. The problem however is that we can’t show value of OTB Created field which contains datetime when document was added to the document library (don’t mix it with file created datetime which is shown when we check file properties in Windows explorer):

Fortunately there is workaround which can be used for achieving the same result. The idea is that we will create new custom field CreatedQP and will copy value from Created field to it. The question is how exactly values will be copied. First approach which comes to the mind is to created calculated field which will just copy value from Created field:

However if we will check available document properties in quick parts we will see that newly created calculated field is not shown there as well. So the only option is to create regular DateTime field and then copy value from Created field to it whether by using workflow or event receiver. In this article I will show how to do it via workflow.

So first of all we need to create new field:

After that we open parent site in Sharepoint Designer and create new List workflow for our document library:

Add new action “Update List Item” and configure it to copy value from Created field of current list item to CreatedQP field:

and finish workflow:

After that we configure workflow to start automatically when new document is added to the document library:

and publish workflow.

Now if we will add new document to the document library, open it in Word and add CreatedQP via Quick parts > Document properties:

created datetime from Sharepoint doclib will be shown in the document:

The drawback of this approach is that users will be able to change value of CreatedQP field via Quick part control. One possible way to avoid it is to try to make CreatedQP field readonly, but I didn’t test this approach by myself.

No comments:

Post a Comment