Hello kind readers….
Some time back I had a requirement to use Taxonomy column values in a custom web part in my Office 365 solution, basically the requirement was to fill a drop down control with all the values of a particular term of a TermSet .
Now with the limitations in office 365 or sandbox solution is with the taxonomy DLL, you cannot access the terms classes in your object model.
Back then, I did try to search ways of doing it but never could come up with something concrete (clearly I didn’t explore deep enough). Today while poking around in the internet and the ECMA script client object model documentation I could come up with a way to query the meta data column (taxonomy) for its terms … and this could become possible when it was coupled with the power web services SharePoint provides out of the box.
Basically it’s a three part process,
- Get the Metadata Field from you web or list using client object model and then get the schema xml of the field (field.get_schemaXml())
- From the Schema XML, get the sspId, TermSetId, TermId and GroupId of the term associated with the column
- Get the http://[Server]/sites/ColumnSite/_vti_bin/TaxonomyClientService.asmx web service and call the GetChildTermsInTermSet and GetChildTermsInTerm web methods to get the required values of the metadata column from the term store
This is all in a nut shell that you need to do for getting the values of a metadata column that too using pure native JavaScript and no need for any third party library or in fact Jquery (in case you want totally native solution, which I sometimes like :) )
Well, enough talking, now the action… so obviously your question must be… "Ok, got the point but how exactly is this to be done?" … hmm well to answer this I have the attached file with this post which contains the code that gets the specified meta data field terms and prints them out in a UL list form in a DIV… this you can modify according to your needs.
You just need to uploaded the attached file (its in .txt format) then add a content editor web part on any page you want the functionality on and then in the CEWP web part properties … in the content link.. Refer to this uploaded text file.
Have a look at the text file to modify the parameter as per your site … comments are provided in the file itself.
All you need to provide are two things at the bottom
- Name of the meta data field you want to get terms from
- URL of the taxonomyclientservice.asmx from the site/list where your column is
Please let me know you find this helpful at all… hope it can open up some doors for functionalities which you missed out before… I wish I explored this earlier.
- "T"