Open Rafaelki opened 4 years ago
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
I am also having this issue with a template that has got a few content types, is there any update on this and if it helps the default content types work fine its only custom ones i.e.
<pnp:ContentTypeBinding ContentTypeID="0x0101" Default="true" /> <pnp:ContentTypeBinding ContentTypeID="0x0120" />
0x0101 = document and 0x0120 = folder
Managed to find a fix/work around for this, so basically took out the custom content types out of the provisioning template and left the default SharePoint ones only in the template.
After the site is created then i basically run a manual process to add my custom content types after, see example code below
`List newSiteList; //add the custom content types to an array var contentTypeIds = new[] { "0x01010015DCFFB4AD974BC99CD2CC41540EA57A03" };
//go through these and add them manually foreach (var contentTypeId in contentTypeIds) { //get the content type by id var contentType = clientContext.Web.ContentTypes.GetById(contentTypeId); //check if we have the content type if (contentType != null) { //add the content type to the current folder newSiteList.ContentTypes.AddExistingContentType(contentType); } }
//commit the content types to the list clientContext.ExecuteQuery();`
Category
[x] Bug [ ] Enhancement
Environment
[x] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013
Expected or Desired Behavior
When running ApplyProvisioningTemplate with a template that has a ContentTypeBinding I expect the library to be created with the specified content type.
Observed Behavior
ApplyProvisioningTemplate throws the following exception:
Microsoft.SharePoint.Client.CollectionNotInitializedException: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
if the template contains a ListInstance with a ContentTypeBinding of a custom content type.I can confirm that this exception is happening with the last 3 versions (3.18, 3.19 and 3.20) and that it was not happening with 3.15. Also, the template is correctly applied using PnP Powershell (3.15, 3.18, 3.19 and 3.20).
Steps to Reproduce
Run site.RootWeb.ApplyProvisioningTemplate(template) with a template containing this element:
Replace "0x01010036DF8ACB058DF9489700B19236BAD594" with a custom content type ID existing in the site.