For one of the requirement, on each keyword save, we need to retrieve the category and the hierarchy of the keywords with corresponding metadata under that category.

The category Id will be used for publishing and hierarchy with metadata will be used for maintaining the details of what data were published as categories and keyword do not have history.

Using webdav url of the keyword, I was able to retrieve category:

Category category = (Category)keyword.Session.GetObject(

Is there any other approach available to retrieve the category?

What method can I use to retrieve the hierarchy details?

  • 4
    Have you checked the OrganizationalItem property?
    – Eric Huiza
    Oct 6, 2014 at 23:52
  • @EricHuiza - Using OrganizationalItem did the trick to retrieve the category. Thanks !!!
    – Hiren Kaku
    Oct 7, 2014 at 18:40

1 Answer 1


The two properties you will need to access to retrieve the owning category and parent keywords are OrganizationalItem and ParentKeywords

To get the Category and the recursive list of parent keywords (to any depth) you could use something like the code below

private static void OnKeywordSavePre(Keyword keyword, SaveEventArgs args, EventPhases phase)
   //Category object
   var owningCategory = keyword.OrganizationalItem;       
   //IList<Keyword> of parent Keywords, recursively
   var parentKeywords = GetAnchestorKeywords(keyword);

private static IList<Keyword> GetAnchestorKeywords(Keyword keyword, IList<Keyword> keywordTrail = null)
         keywordTrail = new List<Keyword>();

      foreach (var word in keyword.ParentKeywords)
         keywordTrail = GetAnchestorKeywords(word, keywordTrail);
   return keywordTrail;

*code is example only, and is not production ready

  • Thanks for your reply, I was looking for a method that will provide me the entire hierarchy instead of looping through and finding out the hierarchy.
    – Hiren Kaku
    Oct 9, 2014 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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