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'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?

share|improve this question
    
Can you help how can you get the value of selected term, and set it in textfield. thanks, –  Aissam Apr 4 at 17:09
add comment

1 Answer

up vote 2 down vote accepted

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

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.