diff --git a/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectListInstance.cs b/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectListInstance.cs index fd71c33916..dcac400861 100644 --- a/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectListInstance.cs +++ b/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectListInstance.cs @@ -130,7 +130,7 @@ public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate templ { scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ListInstances_Updating_list__0_, templateList.Title); var existingList = web.Lists[index]; - var returnTuple = UpdateList(web, existingList, templateList, listParser, scope, isNoScriptSite); + var returnTuple = UpdateList(web, existingList, templateList, listParser, scope, applyingInformation.UpdateContentTypeOnExistingLists, isNoScriptSite); var updatedList = returnTuple.Item1; listParser = returnTuple.Item2; if (updatedList != null) @@ -1265,7 +1265,7 @@ private static XElement PrepareField(XElement fieldElement) return fieldElement; } - private Tuple UpdateList(Web web, List existingList, ListInstance templateList, TokenParser parser, PnPMonitoredScope scope, bool isNoScriptSite = false) + private Tuple UpdateList(Web web, List existingList, ListInstance templateList, TokenParser parser, PnPMonitoredScope scope, bool UpdateContentTypeOnExistingLists = false, bool isNoScriptSite = false) { web.Context.Load(existingList, l => l.Title, @@ -1532,7 +1532,8 @@ private Tuple UpdateList(Web web, List existingList, ListInst isDirty = false; } - if (existingList.ContentTypesEnabled) + //it might make sense to update ContentType on existing list in case we want to add/refresh a ContentType even if users should not choose + if (existingList.ContentTypesEnabled|| UpdateContentTypeOnExistingLists) { ConfigureContentTypes(web, existingList, templateList, false, scope); } diff --git a/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ProvisioningTemplateApplyingInformation.cs b/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ProvisioningTemplateApplyingInformation.cs index 2025f226e3..309e278afb 100644 --- a/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ProvisioningTemplateApplyingInformation.cs +++ b/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ProvisioningTemplateApplyingInformation.cs @@ -54,6 +54,11 @@ public partial class ProvisioningTemplateApplyingInformation /// public bool OverwriteSystemPropertyBagValues { get; set; } + /// + /// If true the ContentTypes on a existing List will be updated or new ones added. Default is false to preserve existing behavior. + /// + public bool UpdateContentTypeOnExistingLists { get; set; } + /// /// If true, existing navigation nodes of the site (where applicable) will be cleared out before applying the navigation nodes from the template (if any). This setting will override any settings made in the template. ///