Last active
August 9, 2018 05:31
-
-
Save AsishP/a435b7c7a0f626159abf437c5eb43ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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