Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top