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
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();
}
}
}
}
- Marc NemegeerJun 06, 2018Brass Contributor
Ok, thanks for the support. Beginners error, did not have the "commit all". Thanks for helping me out :-)
Best regards,
Marc