I would like to get all DCP's in which components have metadata City that contains word "New". This should return "New York", "New Mexico", "New Hampshire" ...

With OData, this is easy:

odata.svc/CustomMetas?$filter=(KeyName eq 'City' and substringof('New',StringValue))&$expand=Component/ComponentPresentations

but, can this be done using broker API ?

Using API I can get all DCP's if I list all the cities by name in the query but is it possible to do a query based on contains condition?

2 Answers 2


When you use the broker API, you can add all sorts of criteria to filter

One of the available criteria is the CustomMetaValueCriteria class, which allows filtering for a custom metadata string value.

It takes a couple of parameters

  • the key of the custom metadata field
  • the value it should filter on
  • an operator like greater than, equal, not equal,...

I guess a statement like this might help you:

Criteria myCriteria = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("City"), "New%", Criteria.Like);
Query myQuery = new Query(myCriteria );
string[] results = myQuery.ExecuteQuery();

Note that this query looks for any city names starting with New. To look for city names containing New, use "%new%" instead.

The query returns a string array of tcm uris, which you can then use to retrieve the appropriate dcps. You might need to add extra filters to specify the publication ID to look in, or to limit item types to just components, or even search for components with a specific schema ID.

More info on using the filters for the broker API can be found here (login required) http://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-D923899D-75AA-4D73-8E79-2DFAC3D124A6

  • Exactly what I needed! Tnx @Harald Dec 4, 2014 at 14:04

Harald answers your question. I just want to throw another option in: you could use a NuGet package for this: (Warning: it's beta and it's written by me)

Install it: Install-Package Tridion.Broker.DSL -Pre

And then:

var dcps = DslQueryBuilder.CreateQuery()
                                .WithCustomMetadataValue(StringQueryEnum.Like, "New%")

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.