public static void CreateProductTaxonomy(ClientContext ctx) { TermStore store = ctx.Site.GetDefaultKeywordsTermStore(); TermGroup productCategoryGroup = store.GetTermGroupByName("OD2"); if (productCategoryGroup == null) { productCategoryGroup = store.CreateTermGroup("OD2", Constants.TAXONOMY_OD2_GROUP_ID.ToGuid(), "Stuff for od2"); } TermSet ts = store.GetTermSet(Constants.TAXONOMY_PRODUCTCAT_TERMSET_ID.ToGuid()); ctx.Load(ts); ctx.ExecuteQuery(); // if term store does not exist create a new one. if (ts.ServerObjectIsNull.Value) { ts = productCategoryGroup.CreateTermSet("Product Category", Constants.TAXONOMY_PRODUCTCAT_TERMSET_ID.ToGuid(), 1033); store.CommitAll(); ctx.Load(ts); ctx.ExecuteQuery(); ts.CreateTerm("Prod Cat 1", 1033, Guid.NewGuid()); ts.CreateTerm("Prod Cat 2", 1033, Guid.NewGuid()); ts.CreateTerm("Prod Cat 3", 1033, Guid.NewGuid()); ts.CreateTerm("Prod Cat 4", 1033, Guid.NewGuid()); store.CommitAll(); ctx.ExecuteQuery(); } }
public static void CreateTaxonomy(ClientContext ctx) { TermStore store = ctx.Site.GetDefaultSiteCollectionTermStore(); TermGroup group = store.GetGroup("{0671B184-F909-4DCA-B383-6E05C969BEF1}".ToGuid()); ctx.Load(group); ctx.ExecuteQuery(); if (group.ServerObjectIsNull()) { group = store.CreateTermGroup("David1", "{0671B184-F909-4DCA-B383-6E05C969BEF1}".ToGuid()); } TermSet ts = group.EnsureTermSet("Color", "{19419441-6982-4978-8800-F12A46E6FE37}".ToGuid(), 1033); // Term term = ts.CreateTerm("Green", 1033, "{FA6628FA-9790-4622-9B54-23D103A67FCD}".ToGuid()); // Term term2 = ts.CreateTerm("Röd", 1053, "{24FA5756-25E8-4257-A4E5-D53C3D48B595}".ToGuid()); // ctx.ExecuteQuery(); // term2.EnsureLabel(1033, "Red", false); Term term2 = ts.CreateTerm("Blue", 1033, "{73E90F88-BD96-4066-8237-2D0DAAE3F11C}".ToGuid()); ctx.ExecuteQuery(); term2.EnsureLabel(1053, "Blå", false); }
public static void CreateTaxonomyFavColor(ClientContext ctx) { TermStore store = ctx.Site.GetDefaultSiteCollectionTermStore(); TermGroup group = store.GetTermGroupByName("School"); if (group == null) { group = store.CreateTermGroup("School", "{13E6924A-196D-4313-A1B4-3A21AF3958CF}".ToGuid(), "description"); } TermSet termSet = group.EnsureTermSet("Fav Color", "{3D4C7DE0-3867-44C3-871A-C36DEC4E1970}".ToGuid(), 1033); Term term = store.GetTerm("{1BB08D14-4464-410C-A27C-BA2EB8EFE9DE}".ToGuid()); ctx.Load(term); ctx.ExecuteQuery(); if (term.ServerObjectIsNull()) { termSet.CreateTerm("Green", 1033, "{1BB08D14-4464-410C-A27C-BA2EB8EFE9DE}".ToGuid()); termSet.CreateTerm("Blue", 1033, "{E96EF7E0-7F9B-4F66-BA1A-C2DBCC73DD78}".ToGuid()); termSet.CreateTerm("Red", 1033, "{13E22744-483D-49D2-B92D-6BD2E0C10D9C}".ToGuid()); ctx.ExecuteQuery(); } }
public static void CreateIssueCategoryTermSet(ClientContext ctx) { //TaxonomySession taxSession = TaxonomySession.GetTaxonomySession(ctx); //TermStore store = taxSession.TermStores[0]; TermStore store = ctx.Site.GetDefaultSiteCollectionTermStore(); TermGroup group = store.GetTermGroupByName("OD1Test"); if (group == null) { group = store.CreateTermGroup("OD1Test", "{13E6924A-196D-4313-A1B4-3A21AF3958CF}".ToGuid(), "description"); } TermSet termSet = group.EnsureTermSet("Issue Category", "{3D4C7DE0-3867-44C3-871A-C36DEC4E1970}".ToGuid(), 1033); Term term = store.GetTerm("{1BB08D14-4464-410C-A27C-BA2EB8EFE9DE}".ToGuid()); ctx.Load(term); ctx.ExecuteQuery(); if (term == null) { termSet.CreateTerm("Just Right", 1033, "{1BB08D14-4464-410C-A27C-BA2EB8EFE9DE}".ToGuid()); termSet.CreateTerm("Low Priority", 1033, "{E96EF7E0-7F9B-4F66-BA1A-C2DBCC73DD78}".ToGuid()); termSet.CreateTerm("Urgent", 1033, "{13E22744-483D-49D2-B92D-6BD2E0C10D9C}".ToGuid()); ctx.ExecuteQuery(); } }
//gavdcodeend 11 //gavdcodebegin 12 static void SpCsPnpcoreCreateTermGroup(ClientContext spCtx) { string termStoreName = "Taxonomy_hVIOdhme2obc+5zqZXqqUQ=="; TaxonomySession myTaxSession = TaxonomySession.GetTaxonomySession(spCtx); TermStore myTermStore = myTaxSession.TermStores.GetByName(termStoreName); TermGroup myTermGroup = myTermStore.CreateTermGroup("CsPnpcoreTermGroup"); }
protected override void ExecuteCmdlet() { var taxonomySession = TaxonomySession.GetTaxonomySession(ClientContext); // Get Term Store TermStore termStore = null; if (TermStore == null) { termStore = taxonomySession.GetDefaultSiteCollectionTermStore(); } else { termStore = TermStore.GetTermStore(taxonomySession); } // Create Group var group = termStore.CreateTermGroup(Name, Id, Description); WriteObject(group); }
static void CreateTerms(ClientContext ctx) { TermStore store = ctx.Site.GetDefaultSiteCollectionTermStore(); Microsoft.SharePoint.Client.Taxonomy.TermGroup group = store.GetTermGroupByName("Tim"); if (group == null) { group = store.CreateTermGroup("Tim", "{9285FBFD-F1B1-44CA-ACFF-8CF4B271A5C2}".ToGuid()); } Microsoft.SharePoint.Client.Taxonomy.TermSet term = group.EnsureTermSet("Animals", "{FCB857B8-8F82-4EDD-B49A-5A5A5D492174}".ToGuid(), 1033); term.CreateTerm("Dog", 1033, "{E6251A5B-8341-4FC9-9544-30670C5E115B}".ToGuid()); Microsoft.SharePoint.Client.Taxonomy.Term cat = term.CreateTerm("Cat", 1033, "{F1D30452-0DD1-4B74-89CA-62167065BFF6}".ToGuid()); term.CreateTerm("Horse", 1033, "{25E73090-CFEF-4A83-997D-56FB127F0B82}".ToGuid()); ctx.ExecuteQuery(); cat.CreateLabel("Katt", 1053, false); cat.CreateLabel("Feline", 1033, false); ctx.ExecuteQuery(); }