Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.DocumentManagement;
// Replace all instances of < > with your variables
using (var context = new ClientContext(<siteUrl>))
{
context.Credentials = new SharePointOnlineCredentials(UserName, SecurePass);
listToOperate = context.Web.GetListByUrl(<listRelUrl>);
context.Load(listToOperate);
context.ExecuteQuery();
//Create the folder first
Folder folder = listToOperate.RootFolder.EnsureFolder(folderName);
context.ExecuteQueryRetry(5);
//Setting the Metadata Defaults for the Folder
MetadataDefaults metadataDefaults = new MetadataDefaults(context, listToOperate);
metadataDefaults.SetFieldDefault(folder, "<ColumnName>", "-1;#" + <taxonomy values>);
metadataDefaults.Update();
listToOperate.Update();
context.ExecuteQuery();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.