Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate templ
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ListInstancesDataRows_Processing_data_rows_for__0_, listInstance.Title);
// Retrieve the target list
var list = web.GetListByUrl(parser.ParseString(listInstance.Url));
web.Context.Load(list);
web.Context.Load(list, l => l.Id, l => l.Title, l=>l.BaseType, l=>l.RootFolder);

// Retrieve the fields' types from the list
Microsoft.SharePoint.Client.FieldCollection fields = list.Fields;
Expand Down Expand Up @@ -198,6 +198,8 @@ public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate templ
WriteMessage(warning, ProvisioningMessageType.Warning);
continue;
}
scope.LogError(CoreResources.Provisioning_ObjectHandlers_ListInstancesDataRows_Creating_listitem_failed___0_____1_, ex.Message, ex.StackTrace);
throw;
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client;
using Newtonsoft.Json;
using PnP.Framework.Diagnostics;
using PnP.Framework.Provisioning.Model;
Expand Down Expand Up @@ -46,7 +46,13 @@ public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplat
var chrome = pnpCoreContext.Web.GetBrandingManager().GetChromeOptions();

footer.Enabled = chrome.Footer.Enabled;
footer.DisplayName = chrome.Footer.DisplayName;
// Avoid setting a null DisplayName, which causes errors if the footer was previously enabled.
// This can happen when a user disables the footer after it was set.
// Only update if DisplayName is present in the template.
if (template?.Footer?.DisplayName != null)
{
chrome.Footer.DisplayName = template.Footer.DisplayName;
}
footer.Layout = (PnP.Framework.Provisioning.Model.SiteFooterLayout)Enum.Parse(typeof(PnP.Framework.Provisioning.Model.SiteFooterLayout), chrome.Footer.Layout.ToString());
footer.BackgroundEmphasis = (PnP.Framework.Provisioning.Model.Emphasis)Enum.Parse(typeof(PnP.Framework.Provisioning.Model.Emphasis), chrome.Footer.Emphasis.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,59 @@ public static void UpdateListItem(ListItem item, TokenParser parser, IDictionary

var context = item.Context as ClientContext;
var list = item.ParentList;
context.Web.EnsureProperty(w => w.Url);

bool isDocLib = list.EnsureProperty(l => l.BaseType) == BaseType.DocumentLibrary;
bool isPagesLib = list.EnsureProperty(l => l.RootFolder).Name.Equals("SitePages", StringComparison.InvariantCultureIgnoreCase);
//Ensure can have unwanted sideeffects as ExecuteQuery is called..
if (!context.Web.IsPropertyAvailable("Url"))
{
context.Web.EnsureProperty(w => w.Url);
}

bool isDocLib = false;
bool isPagesLib = false;

if (list.IsPropertyAvailable("BaseType"))
{
isDocLib = list.BaseType == BaseType.DocumentLibrary;
}
else
{
// Otherwise, ensure the property is loaded
try
{
isDocLib = list.EnsureProperty(l => l.BaseType) == BaseType.DocumentLibrary;
}
catch (Exception ex)
{
Log.Error(Constants.LOGGING_SOURCE, "Error while trying to get list property 'BaseType' for '{0}'. Error: {1}", list.IsPropertyAvailable("Title")?list.Title:"list title not loaded", ex.Message);
//throw;
}
}

if (list.IsObjectPropertyInstantiated("RootFolder") && list.RootFolder.IsPropertyAvailable("Name"))
{
isPagesLib = list.RootFolder.Name.Equals("SitePages", StringComparison.InvariantCultureIgnoreCase);
}
else
{
// Otherwise, ensure the property is loaded
try
{
if(!list.IsObjectPropertyInstantiated("RootFolder"))
{
list.EnsureProperty(l => l.RootFolder);
}
if (!list.RootFolder.IsPropertyAvailable("Name"))
{
list.RootFolder.EnsureProperty(rf => rf.Name);
}
isPagesLib = list.RootFolder.Name.Equals("SitePages", StringComparison.InvariantCultureIgnoreCase);
}
catch (Exception ex)
{
Log.Error(Constants.LOGGING_SOURCE, "Error while trying to get list property 'RootFolder' for '{0}'. Error: {1}", list.IsPropertyAvailable("Title") ? list.Title : "list title not loaded", ex.Message);
//throw;
}
}

var clonedContext = context.Clone(context.Web.Url);
var web = clonedContext.Web;
Expand Down