Quantcast
Viewing all articles
Browse latest Browse all 79

Setting “Allow Fill-In” on taxonomy fields with CSOM

SharePoint taxonomy term sets can be open, allowing users to enter new values in the taxonomy picker. For this to work you also need to enable Allow ‘Fill-in’ choices in the site column settings for the managed metadata field connected to the term set. It took me a while to figure out how to enable this programatically using the client side object model (CSOM). The trick is to first cast the field to a TaxonomyField so you can edit the taxonomy specific properties on the field:

Field field = clientContext.Site.RootWeb.Fields.GetById(new Guid(taxGuid));
TaxonomyField taxField = clientContext.CastTo<TaxonomyField>(field);
clientContext.Load(taxField);
clientContext.ExecuteQuery();
taxField.Open = true;
taxField.CreateValuesInEditForm = true;
taxField.Update();
clientContext.ExecuteQuery();

Viewing all articles
Browse latest Browse all 79

Trending Articles