Skip to content

Commit

Permalink
Merge pull request pnp#2765 from SherpasGroup/fix-folder-token-parsing
Browse files Browse the repository at this point in the history
Fix for token parsing when provisioning folders
  • Loading branch information
jansenbe authored Oct 17, 2020
2 parents 3255343 + 9b8a345 commit 462057a
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate templ

#endregion Views

#region Column default values

foreach (var listInfo in processedLists)
{
var defaultFolderValues = new List<Entities.IDefaultColumnValue>();
foreach (var templateListFolder in listInfo.TemplateList.Folders)
{
var folderName = templateListFolder.Name;
ProcessDefaultFolders(web, listInfo, templateListFolder, folderName, defaultFolderValues, parser);
}
listInfo.SiteList.SetDefaultColumnValues(defaultFolderValues, true);
}

#endregion Column default values

#region Folders

// Folders are supported for document libraries and generic lists only
Expand Down Expand Up @@ -230,21 +245,6 @@ public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate templ
}

#endregion Property Bag Entries

#region Column default values

foreach (var listInfo in processedLists)
{
var defaultFolderValues = new List<Entities.IDefaultColumnValue>();
foreach (var templateListFolder in listInfo.TemplateList.Folders)
{
var folderName = templateListFolder.Name;
ProcessDefaultFolders(web, listInfo, templateListFolder, folderName, defaultFolderValues);
}
listInfo.SiteList.SetDefaultColumnValues(defaultFolderValues, true);
}

#endregion Column default values
}
WriteMessage("Done processing lists", ProvisioningMessageType.Completed);
}
Expand All @@ -253,20 +253,20 @@ public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate templ
}

private static void ProcessDefaultFolders(Web web, ListInfo listInfo, Model.Folder templateListFolder, string folderName,
List<IDefaultColumnValue> defaultFolderValues)
List<IDefaultColumnValue> defaultFolderValues, TokenParser parser)
{
foreach (KeyValuePair<string, string> columnValue in templateListFolder.DefaultColumnValues)
{
string fieldName = columnValue.Key;
string fieldName = parser.ParseString(columnValue.Key);
var field = listInfo.SiteList.Fields.GetByInternalNameOrTitle(fieldName);
var defaultValue =
field.GetDefaultColumnValueFromField((ClientContext)web.Context, folderName, new[] { columnValue.Value });
field.GetDefaultColumnValueFromField((ClientContext)web.Context, folderName, new[] { parser.ParseString(columnValue.Value) });
defaultFolderValues.Add(defaultValue);
}
foreach (var folder in templateListFolder.Folders)
{
var childFolderName = folderName + "/" + folder.Name;
ProcessDefaultFolders(web, listInfo, folder, childFolderName, defaultFolderValues);
ProcessDefaultFolders(web, listInfo, folder, childFolderName, defaultFolderValues, parser);
}
}

Expand Down Expand Up @@ -2205,7 +2205,7 @@ private void CreateFolderInList(ListInfo list, Microsoft.SharePoint.Client.Folde
parentFolder.Context.ExecuteQueryRetry();
foreach (var p in folder.Properties.Where(p => !p.Key.Equals("ContentTypeId")))
{
currentFolderItem[p.Key] = parser.ParseString(p.Value);
currentFolderItem[parser.ParseString(p.Key)] = parser.ParseString(p.Value);
}
#if !SP2013 && !SP2016
currentFolderItem.UpdateOverwriteVersion();
Expand All @@ -2230,7 +2230,7 @@ private void CreateFolderInList(ListInfo list, Microsoft.SharePoint.Client.Folde
{
foreach (var p in folder.PropertyBagEntries)
{
currentFolder.Properties[p.Key] = parser.ParseString(p.Value);
currentFolder.Properties[parser.ParseString(p.Key)] = parser.ParseString(p.Value);
}
currentFolder.Update();
}
Expand Down

0 comments on commit 462057a

Please sign in to comment.