Forum Discussion
Marc Nemegeer
Jun 05, 2018Brass Contributor
CSOM Update "Other labels" of a term
Hi, It looks like modifying the "other labels" using CSOM is not supported. Or at least I did not get it working. Can somebody explain me how to do it ? Getting the term, loading the "labels col...
- Jun 05, 2018
I wrote a quick sample application for you to demonstrate:
using Microsoft.SharePoint.Client.Taxonomy;
using OfficeDevPnP.Core;
namespace TermLabelUpdater
{
class Program
{
static void Main(string[] args)
{
using (var ctx = new AuthenticationManager().GetSharePointOnlineAuthenticatedContextTenant("", "", ""))
{
var taxonomySession = TaxonomySession.GetTaxonomySession(ctx);
var termStore = taxonomySession.GetDefaultSiteCollectionTermStore();
var termGroup = termStore.Groups.GetByName("Test");
var termSet = termGroup.TermSets.GetByName("Test");
var term = termSet.Terms.GetByName("Test");
ctx.Load(term, t => t.Labels);
ctx.ExecuteQuery();
var label = term.Labels[2];
label.Value = "UPDATE!";
termStore.CommitAll();
ctx.ExecuteQuery();
}
}
}
}
paulpascha
Jun 05, 2018Bronze Contributor
Modifying Term Labels using CSOM should work just fine. Please make sure you call TermStore.CommitAll() followed by ClientContext.ExecuteQuery() to save your changes. If you don't already have one, you can get a reference to TermStore from your Term object... (term.TermStore)
Hope this helps!