2

Suppose I have a component used in many pages' components which I want to update based on a specific schema. It's not feasible to do this manually so I'm writing a small Core Service console app to do this for me.

So far I have:

var filter = new UsingItemsFilterData
{
    BaseColumns = ListBaseColumns.Id,
    ItemTypes = new[] { ItemType.Component }
};

var results = CoreServiceFactory.CreateCoreService().GetListXml("tcm:xx-xxxxxx", filter);
Console.WriteLine($"Components Found: {results.Nodes().Count()});

This returns 500+ components. Inspecting the results, it's returning a list of TCM IDs.

Is there a way to specify via UsingItemsFilterData to return items of a certain ItemTypes AND Schema so that I can further reduce the number of items returned? Is there another way I can do this apart from my current approach?

I'm unable to find an appropriate method within the documentation (ICoreService201603).

1

Sorry to disappoint you but no. You do here a two stage filtering. First you get all ITEMS that use your component which are of type Component. After you get the total list of more than 500 items, you must cast them to ComponentData object (first stage filtering)., and filter based on their schema (second stage filtering).

You can use LINQ to speed up the filtering, but still, it must be two stage, because UsingItemsFilterData returns ITEMS, not Components specific.

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.