Forum Discussion

Marc Nemegeer's avatar
Marc Nemegeer
Brass Contributor
Jun 05, 2018
Solved

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...
  • paulpascha's avatar
    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();
    }
    }
    }
    }