1

I need to query for components that all have the same component linked inside a multi-value component link field.

I can query simple string fields without problem using CustomMetaKeyCriteria/CustomMetaValueCriteria but I cant find a solution trying to ask for a common component.

This is my field definition for the main component

Field definition

And this is a component with the multi-value field filled.

Component example

The closest result I got is if I only ask for components with the multi-value field filled with anything.

{
"SortingClass": "Sorting",
"Sorting": "{\"sortParameters\":[]}",
"CriteriaClass": "AndCriteria",
"Criteria": "{\"criteriaName\":\"AND\",\"criteriaChildren\":[{\"CLASSNAME\":\"PublicationCriteria\",\"INSTANCE\":{\"publicationId\":5,\"criteriaName\":\"PublicationCriteria\",\"criteriaChildren\":[],\"isOperator\":false,\"operator\":\"EQUAL\"}},{\"CLASSNAME\":\"ItemSchemaCriteria\",\"INSTANCE\":{\"publicationId\":5,\"schemaId\":514,\"criteriaName\":\"ItemSchemaCriteria\",\"criteriaChildren\":[],\"isOperator\":false,\"operator\":\"EQUAL\"}},{\"CLASSNAME\":\"CustomMetaKeyCriteria\",\"INSTANCE\":{\"keyName\":\"poi\",\"criteriaName\":\"CustomMetaKeyCriteria\",\"criteriaChildren\":[],\"isOperator\":false,\"operator\":\"EQUAL\"}}],\"isOperator\":true,\"operator\":\"EQUAL\"}"

}

I would like to ask, for example, for all components that have the component link "POI - Citadel"

7
  • Hi, welcome to Tridion Stack exchange, David! Are these links in the linking Component's metadata? If so, are you able to use the CustomMetaValueCriteria filter to check on values? Mar 8, 2022 at 23:56
  • Hi Alvin. I tried but CustomMetaValueCriteria only seems to work with simple data types. How would you build a criteria to ask for a component? And yes the linking is inside component's metadata. Mar 9, 2022 at 10:41
  • Hmm, it's be a while since I've worked with the criteria filters, but I'd first start with pulling the item's (custom) metadata in Content Delivery. I'm guessing the multi-value field will come back in some format (array, strings, or numbers perhaps). And then that'll tell you what to look for via CustomMetaValueCriteria. Mar 9, 2022 at 14:39
  • 1
    OK - with your use case (linking POIs to a given hotel) I wonder if you can't just publish the POI IDs with your hotel page or component? Then use these to fetch them on the delivery side. If you want to dynamically add or remove POIs then perhaps using a keyword might be a better option. (Tag POIs with keywords that map to the hotel(s) they "belong" to)
    – Nuno Linhares
    Mar 11, 2022 at 8:07
  • 1
    Thanks @NunoLinhares. I'll give it a try. I'll talk to the content team to see if its possible to change the data model. Mar 11, 2022 at 8:46

0

Your Answer

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

Browse other questions tagged or ask your own question.