Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I found the GetFieldValue(string value) function but this requires that you pass it a value that serves as the identifier for the value to be retrieved (i think).

I just want to get all of the possible values for the TaxonomyField, can this be done?

share|improve this question
add comment

2 Answers

If you want to get all the possible values for a TaxonomyField, you can use a method similar to this:

  private TermCollection GetAllValuesForField(SPWeb spWeb, SPList spList, string fieldDisplayName)
    {
        // create new TaxonomySession based on the current Site
        TaxonomySession taxonomySession = new TaxonomySession(spWeb.Site);

        // connect to the Term Store
        TermStore termStore = taxonomySession.TermStores["Term Store Name"];

        // connect to the Term Store Group
        var group = termStore.Groups["Term Group Name"];

        // get a reference to the TaxonomyField (I'm using a TaxonomyField in a SharePoint List)
        TaxonomyField taxField = spList.Fields[fieldDisplayName] as TaxonomyField;

        // get the term set based on the ID (from the taxonomy field)
        var termSet = group.TermSets[taxField.TermSetId];

        return termSet.GetAllTerms();
    }
share|improve this answer
add comment

Yes, that can be done. You need to know the term set to which your TaxonomyField is associated. You can then read all the terms (in other words, all possible values for your taxonomy field) that belong to the term set.

Check following:

http://blogs.pointbridge.com/Blogs/kakanur_kiran/Pages/Post.aspx?_ID=4

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.