I am attempting to set default values for columns in a document list in SharePoint using the PnP.Core SDK. I can successfully set the values and then query them and get the default values back:
private async Task SetFolderDefaultValues(IFolder folder, MyEvent event)
{
var defaultColumnValues = new List<DefaultColumnValueOptions>()
{
new()
{
FolderRelativePath = folder.ServerRelativeUrl,
FieldInternalName = "Project_Number",
DefaultValue = event.ProjectId
},
// ... other properties
};
var list = await _sharePointContext.Web.Lists.GetByServerRelativeUrlAsync(WorkingDirectoryRootRelativePath);
await list.SetDefaultColumnValuesAsync(defaultColumnValues);
var loadedDefaults = await list.GetDefaultColumnValuesAsync(); // Success! This contains the values I just set.
}
The problem is whenever I upload a new file anywhere inside this folder, the file does not contain the default values that were set with that code. I also looked in the settings located at /sites/MySite/_layouts/15/ColumnDefaults.aspx
and found the default value column doesn't contain the default values I set even though they come back in that GetDefaultColumnValuesAsync()
call successfully.
How do I set default column values for a specific folder using the Pnp.Core SDK?