-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand the taxonomy support with methods to search/load terms at store level #892
Comments
Also a way getting a termset (GetTermSetById) without knowing the term group would be nice. |
Also replacements or alternatives for the following CSOM methods will be helpful. Microsoft.SharePoint.Client.Taxonomy.TermStore
Microsoft.SharePoint.Client.Taxonomy.TermGroup Microsoft.SharePoint.Client.Taxonomy.TermSet
Maybe the searchTerm (Rest API, Graph API, whatever ...) can be used to replace some of these CSOM methods like |
From @gszdev: Moving the TaxonomyExtensions.GetWssIdForTerm from PnP Framework to PnP Core SDK would also be helpfull. Here's the link to the PnP Framework (CSOM) implementation: I'm new to PnP Core SDK so I'm not able to create a pull request because I don't know where how to put the methods in (IWeb, ITermStore, ...). Here's my code snipped (Extension Methods) for PnPCore SDK:
` |
@gszdev : as mentioned above needed Graph APIs currently are not present, but they've been added to the respective team's backlog |
…ing a termset without knowing the termset group #892
… to enable loading a termset or term without knowing the termset group #892
@gszdev : I've added methods on What's still missing is loading a term with just knowing it's id or searching for a term based upon it's label, currently there's no graph method that directly can get a term from the termstore without knowing the termset. |
and
This is possible now, see previous comment |
Thank you very much. |
@gszdev : yes, the new methods will appear in the nightly build and will be part of the 1.7 release coming this week. I've also just added |
Hi, |
@Nevinia210 : Can you check Term.Parent.Parent...Parent can be term collection, but the parent of the termcollection can be another term |
@jansenbe |
@Nevinia210 : Is your Term a child of another Term? |
@jansenbe : yes, its Level3 in this case: |
@Nevinia210 : think this is due to way you load the term then? In my test case (see here). Breakpoint was on line 972. |
@jansenbe : i tried your approach with loading terms but still not success, am i missing something? var siteMapTermSet = pnpContext.TermStore.GetTermSetById(selectedTermSetId.ToString());
await siteMapTermSet.LoadAsync(p => p.Terms);
var selectedTerm = siteMapTermSet.Terms.GetById(taxField.TermId.ToString());
await selectedTerm.LoadAsync(x => x.Terms);
var test = (ITerm)selectedTerm.Parent; // System.InvalidCastException: 'Unable to cast object of type 'PnP.Core.Model.SharePoint.TermCollection' to type 'PnP.Core.Model.SharePoint.ITerm'.'
var test2 = (ITerm)selectedTerm.Parent.Parent;// System.InvalidCastException: 'Unable to cast object of type 'PnP.Core.Model.SharePoint.TermSet' to type 'PnP.Core.Model.SharePoint.ITerm'.' |
@Nevinia210 : this will not work in that way, the Parent model is built based upon a step by step loading of model instances, if you directly load a given term then there's no full parent tree available. Probably easiest for now is loading the termset and then iterating over the terms...The Graph API has not support to directly load the parent term of a term, so no easy way out of this if you're no enumerating the whole termset |
@gszdev / @Nevinia210 : I'll close this issue as we're currently using all the possible taxonomy Graph APIs. There most likely will be additional API later this year and once they ship, we'll integrate them in PnP Core SDK. |
From @gzdev in #849:
Support for new TermStore Rest API _api/v2.1/termStore (used in ModernExperience).
For example: CSOM (Microsoft.SharePoint.Client) offers a way to search for Terms using the one of the following methods:
Microsoft.SharePoint.Client.Taxonomy.TermStore.GetTerms(LabelMatchInformation labelMatchInformation)
RestApi EndPoint: {SiteUrl}/_api/v2.1/termStore/searchTerm(label='{WordsToSearchFor}',languageTag='en-US')?$expand=set
PnP JS has already implemented the searchTerm method (Link to PnP JS GitHub Report -> searchTerm docs)
Microsoft.SharePoint.Client.Taxonomy.TermStore.GetTermsById(Guid[] termIds)
Get multiple Terms by Id without loading the FieldInfo to get the TermSet.Id to get the TermSet and then getting each Term by Id, ...
I don't know wether there is any RestApi EndPoint to offer such a way to get multiple terms at once.
Also a way getting a term (GetTermById) without knowing the term group would be nice.
Is there a way to get these features in PnP Core SDK?
Btw do anyone know where the documentation of _api/v2.1/termStore clould be found?
Response:
@gszdev , thanks for the feedback, these indeed are useful extensions to have. We're using Microsoft Graph for taxonomy support , will need to check if this is possible using Graph. Using the v2.1 endpoint is not something we support today and (theoretically) this end point is the SharePoint proxy for Graph and one should prefer using Graph over v2.1 whenever possible.
For getting multiple terms in one go batching might be the solution, will investigate that as well.
Update: quick research showed that both requests are not possible today using Microsoft Graph. I'll check with the Graph team owning these features, plan B could be to wrap the CSOM endpoints (like we do for some other missing methods). I'll create a separate issue to track this request.
The text was updated successfully, but these errors were encountered: