Introduction
Playing with PnP Provisioning is funny as you have different set of features and requirements you can achieve when provisioning sites.
Last month I found sort of bug at version v2.4.1605 of PnP Core: Can not Convert Object when provisioning pnp:file Display Template.
Working with the same version I had a requirement to provision a Content Type that inherits of Item but we MUST hide OOTB Title column and provision List Instance, bind the Content Type to the new List and enable contextual menu on the Custom_Title field.
If it is the first time you use the PnP Provisioning, please highly recommends you look into this GitHub page (where MS publish the PnP Core solution).
Using PnP Provisioning:
I will quick remind a step by step to start using PnP Provisioning:
- Create Console Application to invoke PnP Core classes.
Add Packages needed using Package Manager Console. Here is how my packages.config looks like:
Now, we can see OfficeDevPnP.Core in our Project References:
Create a function to read the XML file (Provisioning Template) and Apply it to Web object on SharePoint or Office 365.
Call this function from Main method but before configure your environment settings.
Create a two folders in your Project:
- Assets folder: where you can put all the files you need to provision (Display Templates, Master Pages, JS, CSS, Page Layouts, WebParts, etc.)
- Config folder: where you can put all your Provisioning Template xml files.
Create Site Collection level Provisioning Template (JQ.SiteCollection.Template.xml):
In this case, we will Provision:
- A new Hyperlink field.
A new Text field used as a Custom Title. It is important to use these four attributes to enable the field as a Link and Menu in the SharePoint views:
1
2
3
4LinkToItemAllowed="Required"
LinkToItem="True"
ListItemMenuAllowed="Required"
ListItemMenu="True"Thank you Dario for your post: Linking a custom column to the Item and the Item menu.
- A new Content Type that inherits of Item but with the two new fields previously created and OOTB Title column hidden.
Create Sub-site level Provisioning Template (JQ.Resources.Template.xml).
A new list will be provisioned using and binding to the previously created Content Type.
Conclusion
This is how the solution looks at the end, and we have meet two requirements: