question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding existing content types to library deletes them in 1.3.0

See original GitHub issue

I am adding extra content types defined on the Site level to the “Documents” library via a provisioning template (first, third and fourth line in pnp:ContentTypeBindings):

      <pnp:Lists>
        <pnp:ListInstance Title="Dokumenty" Description="" DocumentTemplate="{site}/Sdilene dokumenty/Forms/template.dotx" OnQuickLaunch="true" TemplateType="101" Url="Sdilene dokumenty" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="500" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" ContentTypesEnabled="true" EnableAttachments="false" DefaultDisplayFormUrl="{site}/Sdilene dokumenty/Forms/DispForm.aspx" DefaultEditFormUrl="{site}/Sdilene dokumenty/Forms/EditForm.aspx" DefaultNewFormUrl="{site}/Sdilene dokumenty/Forms/Upload.aspx" ImageUrl="/_layouts/15/images/itdl.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ReadSecurity="0" WriteSecurity="0" ValidationFormula="" ValidationMessage="" EnableFolderCreation="false" >
          <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x010100BF87545EA10ECE43B34F659BC08D9129" Default="true"/>
            <pnp:ContentTypeBinding ContentTypeID="0x0120"/>
            <pnp:ContentTypeBinding ContentTypeID="0x0120D52000E31C3CDFB447B943AA017C95EE1660BA"/>
            <pnp:ContentTypeBinding ContentTypeID="0x0101008D022B8BE33B8242BD95268C8C48D66C"/>
            <pnp:ContentTypeBinding ContentTypeID="0x0101" Remove="true"/>
            <pnp:ContentTypeBinding ContentTypeID="0x0120D520" Remove="true"/>            
          </pnp:ContentTypeBindings>

image

In PnP.PowerShell 1.2.0 it worked as expected, but after installing 1.3.0 version, it suddenly started to delete the content types from the library.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
makovickanavisyscommented, Feb 18, 2021

Tested on 1.3.7 and it worked correctly.

1reaction
makovickanavisyscommented, Feb 17, 2021

Attaching simplified template for Shared Documents - it creates a test site content type and then tries to attach the content type to the Shared Documents library (and delete default Document content type):

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2020/02/ProvisioningSchema">
  <pnp:Preferences Generator="PnP.Framework, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null" />
  <pnp:Templates ID="CONTAINER-TEMPLATE-F58EE98711994592B93E425E2328DF33">
    <pnp:ProvisioningTemplate ID="TEMPLATE-F58EE98711994592B93E425E2328DF33" Version="1" BaseSiteTemplate="STS#3" Scope="RootSite">
    
      <pnp:ContentTypes>
        <pnp:ContentType ID="0x01010068C42A1C3BC050409A16B485D2F08CEB" Name="TestContentType" Description="Create a new document." Group="Custom Content Types" NewFormUrl="" EditFormUrl="" DisplayFormUrl="">
          <pnp:FieldRefs>
            <pnp:FieldRef ID="c042a256-787d-4a6f-8a8a-cf6ab767f12d" Name="ContentType" UpdateChildren="true" />
            <pnp:FieldRef ID="5f47e085-2150-41dc-b661-442f3027f552" Name="SelectFilename" UpdateChildren="true" />
            <pnp:FieldRef ID="8553196d-ec8d-4564-9861-3dbe931050c8" Name="FileLeafRef" Required="true" UpdateChildren="true" />
            <pnp:FieldRef ID="8c06beca-0777-48f7-91c7-6da68bc07b69" Name="Created" Hidden="true" UpdateChildren="true" />
            <pnp:FieldRef ID="fa564e0f-0c70-4ab9-b863-0177e6ddd247" Name="Title" UpdateChildren="true" />
            <pnp:FieldRef ID="28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f" Name="Modified" Hidden="true" UpdateChildren="true" />
            <pnp:FieldRef ID="822c78e3-1ea9-4943-b449-57863ad33ca9" Name="Modified_x0020_By" UpdateChildren="true" />
            <pnp:FieldRef ID="4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb" Name="Created_x0020_By" UpdateChildren="true" />
          </pnp:FieldRefs>
        </pnp:ContentType>
      </pnp:ContentTypes>
      
      <pnp:Lists>
        <pnp:ListInstance Title="Documents" Description="" DocumentTemplate="{site}/Shared Documents/Forms/template.dotx" OnQuickLaunch="true" TemplateType="101" Url="Shared Documents" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="500" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" ContentTypesEnabled="true" EnableAttachments="false" DefaultDisplayFormUrl="{site}/Shared Documents/Forms/DispForm.aspx" DefaultEditFormUrl="{site}/Shared Documents/Forms/EditForm.aspx" DefaultNewFormUrl="{site}/Shared Documents/Forms/Upload.aspx" ImageUrl="/_layouts/15/images/itdl.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
          <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x0101" Remove="true"/>
            <pnp:ContentTypeBinding ContentTypeID="0x0120" />
            <pnp:ContentTypeBinding ContentTypeID="0x01010068C42A1C3BC050409A16B485D2F08CEB" Default="true" />
          </pnp:ContentTypeBindings>
          <pnp:Views>
            <View Name="{5E1AA7E5-1152-4E28-B490-4AC1F75355FA}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Documents" Url="{site}/Shared Documents/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=47">
              <Query>
                <OrderBy>
                  <FieldRef Name="FileLeafRef" />
                </OrderBy>
              </Query>
              <ViewFields>
                <FieldRef Name="DocIcon" />
                <FieldRef Name="LinkFilename" />
                <FieldRef Name="Modified" />
                <FieldRef Name="Editor" />
              </ViewFields>
              <RowLimit Paged="TRUE">30</RowLimit>
              <JSLink>clienttemplates.js</JSLink>
            </View>
          </pnp:Views>
        </pnp:ListInstance>
      </pnp:Lists>
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

On 1.2.0 it works, on 1.3.0 it tries to delete the “TestContentType” from the library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a content type to a list or library
Go to the settings for the list or library. Under Content Types, select Add from existing site content types. If Content Types doesn't...
Read more >
13 Working with Libraries
This chapter describes how to create, secure, modify, and delete libraries. It has the following topics: About Document Libraries · Creating an Enterprise ......
Read more >
Library administration
Delete libraries. This action is only available if there are no content using the library and there are no other libraries dependent of...
Read more >
Add-Remove Content Types to SharePoint List or Library ...
On the “Add Content Types” page, in the “Available Site Content Types” section, select the content types you want to add to the...
Read more >
Appcompat | Jetpack
Declaring dependencies. To add a dependency on Appcompat, you must add the Google Maven repository to your project. Read Google's Maven repository for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found