Skip to main content
1 of 2
Saurabh Gangwar
  • 6.5k
  • 1
  • 16
  • 32

So If you have title for the keyword and know the category attached to the component field, You can use below function to get the keyword id.

string GetKeywordId(string KeywordTitle, string categoryID)
        {
            KeywordsFilterData kwdFilter = new KeywordsFilterData();
            
            var query1 = from XElement r1 in tridionClient.GetListXml(categoryID, kwdFilter).Descendants()
                         where r1.Attribute("Title").Value.ToLower() == KeywordTitle.ToLower()
                         select r1;
            XElement foundNode = query1.FirstOrDefault();
            if (foundNode != null)
            {
                   string keywordID = foundNode.Attribute("ID").Value;
                   return keywordID;
            }

            return "";
        }
Saurabh Gangwar
  • 6.5k
  • 1
  • 16
  • 32