2

I've got a "Managed Metadata" column on a document library (required field). When I've added a document, I need to get te level of the selected term in my term store. I'm using a eventreceiver. I know how to get the value of the selected term, but not how to get the level...

Example:

  • TermSetName --> level 0
    -- Term1 --> level 1
    -- Term2 --> level 1
    --- Term2.1 --> level 2
    --- Term2.2 --> level 2
    --- Term2.3 --> level 2
    -- Term3 --> level 1

So when I select Term2.2, I want to get the level: 2
Anyone knows how to do this?

  • Can you help how can you get the value of selected term, and set it in textfield. thanks, – Aissam Apr 4 '14 at 17:09
3

If you have got hold of Term object, you can call its GetPath method to get a list of its ancestor separated by semi column(;). You can then split and find the index of last item in the split array. Check GetPath method here:

http://msdn.microsoft.com/en-us/library/ee584878.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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