Query a SPList with managed metadata column with CAML including child terms
-
06-10-2020 - |
Frage
I have a SharePoint list which has a managed metadata column. This is bound to my term store which look like as following:
- Cars
- Mercedes
- S600
- CL65
- G
- BMW
- 5
- 6
- 7
- X5
- Maybach
- ...
- Bentley
- Mercedes
I want to query via CAML this list. I have a custom application page where the user is able to select the terms from the term store by drop downs. Given is a ListItem where the user has selected the term "S600" from the parent term "Mercedes". Lets think that the user now only selects "Mercedes".
How can I query the list with CAML so that I also get all items which where tagged with the children of the term "Mercedes"?
In short: How can I build a CAML query which can get all items with the selected parent terms child terms?
Lösung
The magic words are TaxonomyField.GetWssIdsOfTerm.
This question is a dupicate of https://stackoverflow.com/questions/5258722/how-does-one-get-all-child-terms-of-a-sharepoint-term-in-c.