SharePoint’s document libraries do provide the option to apply default metadata OOTB, however this method has the following cons:
- Sites that feature multiple document libraries take additional effort to configure
- If something important such as the project manager changes, updating the default value won’t update existing items
Making use of a lookup column might not be flawless but in practice it works a treat for project & team collaboration sites, offering the following pro’s:
- The additional columns associated with the lookup column are crawled, allowing full search functionality such as refiners and sorting.
- The solution works fine with content type publishing – enterprise ready
- Site information only needs to be entered once no matter how many document libraries/lists the site features
- Updating existing items is as simple as updating the parent list item – The actual documents are not modified so this also benefits your SQL Servers.
- As an added bonus the site information can be utilised to create site directories.
It does however have the following cons:
- The lookup column has limitations around which column types can be associated. Person, choice and managed metadata can’t. Text & Date are fine though.
- Due to the items date/time not being modified, search will not reflect any changes to the parent item until any of the following.
- A full crawl takes place
- The document library is marked for re-indexing
- The child item is modified
This guide is intended for enterprise level configuration with the least amount of steps, in real world additional columns and content types should be used. Configuring a single site is still possible, its just a case of creating everything locally within the site.
Tip – If you don’t have a naming convention for the internal names of columns, I highly recommend you at the least don’t include spaces.
Content Type Hub Config
To get things started the content type hub will need the following components:
- Project Site Properties Content Type
- Project Owner – Text (Site Column)
- Project Start Date – Date (Site Column)
- Project Document Content Type
- Properties List
- With the above components in place, add the Project Site Properties content type to the Properties list
- Create an item in the properties list (Note Never delete this item)
- Create a lookup (site column) named Project Details, pointing to the title column within the properties list, adding the Project Owner & Start Date columns as associated columns.
- Add the Project Details column to the Project Document content type, ensure you set this column to hidden – Don’t be tempted to leave it as optional, this won’t work.
- Use the script within this post to set the default value of your project Project Details column to 1. A title is not needed, just the ID of 1 will do.
- To test the default value, amend the following rest call to match your site and column then paste it into your browsers address bar – https://YourSite/_api/web/fields/getbytitle(‘Project Details‘)/defaultvalue .It should match the following screenshot
- For completeness its worth adding the Project Document content type to a document library within the content type hub then uploading a document, after adding your columns into a view, the project details fields should be populated as shown in the following screenshot
- With everything present and correct, you can now safely publish the Project Site Properties & Project Document content types
Project Site Configuration
Upon checking the content type publishing error log in any new sites, you’ll notice the following error:
This is due to the properties list and columns that the Project Details column links to, so the following steps are required to configure a project site:
- Create a list named Properties then add the Project Site Properties content type to it
- From Site Settings – > Content type publishing, check the Refresh all published content types on next update box.
- Wait for the Project Details column to be present within the Project Document content type – Note on premise you can run the associated timer jobs to avoid having to wait.
- Add an item to the properties list. Important Note – The lookup column defaults to this item by its ID, so you should think about ways to ensure users don’t delete it.
- Add the Project Document content type to any document libraries you have within the site
Additionally the Project Details column can now be added to other content types such as images & videos.
Note – This solution has been tested with site templates and works just fine (removing the need for any of the project site configuration steps). To utilise any of the Office 365 PNP site provisioning techniques, you would need to find a way how to programmatically refresh content types after building the site – I haven’t looked into this yet.
I’ll be writing up another blog post, detailing how to configure search so that users can easily find and identify project sites & project content.