Set List Column Multi Value in SharePoint using CSOM

The example in this topic show how to use CSOM to Set List Column Multi Value in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  • using Microsoft.SharePoint.Client.Taxonomy;
  •  
  • using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
  • {
  • // clientcontext.Web.Lists.GetById - This option also can be used to get the list using List GUID
  • // This value is NOT List internal name
  • List targetList = clientcontext.Web.Lists.GetByTitle("List Name");
  •  
  • // Get field from list using internal name or display name
  • Field oField = targetList.Fields.GetByInternalNameOrTitle("MMS Column Name");
  •  
  • clientcontext.Load(oField);
  • clientcontext.ExecuteQuery();
  •  
  • if (oField.TypeDisplayName == "Managed Metadata")
  • {
  • // cast field to "TaxonomyField"
  • TaxonomyField targetField = clientcontext.CastTo<TaxonomyField>(oField);
  •  
  • // If you set this calue to 'true', the user will be allowed to enter multiple values for this column
  • targetField.AllowMultipleValues = true;
  • targetField.Update();
  • clientcontext.ExecuteQuery();
  • }
  • }

Thank you for reading this article. This code was tested in SharePoint 2013

We value your feedback:

Page URL:

Name:

 

Email:

 
 

Feedback:

 

© 2019 Code SharePoint