0

We need to get all the normal keywords inside the abstract keywords: for example we have 2 normal keywords hotelA and HotelB:

  • hotel(category)
  • United States (abstract keyword)
    • North Dokota (abstract keyword)
      • Fargo(abstract keyword)
        • HotelA (normal keyword)
        • HotelB (normal keyword)

How can we get keyword of hotelA and HotelB using the tcm id of United States using coreservice client?

5
  • Binod , Can you please share your tridion version if possible. – Anand NS May 4 at 11:34
  • Also - what did you try thus far? What challenges are you experiencing? – Dylan .. Mark Saunders May 4 at 12:07
  • currently we are using tridion version 8.5 @AnandNS – Binod May 4 at 12:20
  • we are trying to get the hotel information using country keywords @Dylan..MarkSaunders – Binod May 4 at 12:22
  • What I mean, @Binod, is can you indicate what interaction you've already tried with the Core services? was it prompted from other suggestions in TREX, from Blogs etc.? what results did it yield? – Dylan .. Mark Saunders May 5 at 13:23
1

In general, to get a list of items related to some subject, you can use the Core Service methods GetList (returns Data Objects) or GetListXml (returns so-called R5 XML).

Specifically, to get a list of child Keywords, you use one of those methods in combination with a filter of type ChildKeywordsFilterData.

If you only want to get the "normal"/"concrete" (i.e. not abstract) Keywords, you can specify ChildKeywordsFilterData.IsAbstract = false.

1
  • as we need to find the normal keyword nested inside another abstract keywords ChildKeywordsFilterData will only get the keywords inside level one only – Binod yesterday
0

the solution which i have written will be a recursive function which is not effective but it works.

public static IEnumerable<XElement> getChildKeywords(string tcmId)
            {
                var normalkeywordFilter = new ChildKeywordsFilterData() { IsAbstract = false };
                var normalKeywords = client.GetListXml(tcmId, normalkeywordFilter).Elements().ToList();
    
                if (normalKeywords.Count() != 0) return normalKeywords;
    
                var allabstractKeywords = con.client.GetListXml(tcmId, new ChildKeywordsFilterData() { IsAbstract = true }).Elements().ToList();
                foreach (var el in allabstractKeywords)
                {
                    normalKeywords.AddRange(getChildKeywords(el.Attribute("ID").Value).ToList());
                }
    
                return normalKeywords;
            }

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.