Getting used items using the core service

Just wanted to post up a quick code snippet showing how to get a list of used items XML using the SDL Tridion 2011 core service.  Why?  Well previously the API typically used to work like itemType.GetListUsedItems() (where itemType is a Component or Page object etc), where as now the ‘Using’ and ‘Used’ items are read using a filter via the core service client method .GetListXML().

The example:

            // Create a filter
            UsedItemsFilterData usingItemsFilterData = new UsedItemsFilterData
                BaseColumns = ListBaseColumns.Id, // to specify the detail in the XML
                ItemTypes = new[] { ItemType.Folder, ItemType.Schema, ItemType }  // to specify certain items
            // Get the XML by calling .GetListXml on the client (assumes you have a 'client' object already)
            XElement usingXML = client.GetListXml("tcm:4-283", usingItemsFilterData);

If you’re looking to get the Using Items, for an item, you can simply use a UsingItemsFilterData filter in exactly the same way – enjoy :)

2 thoughts on “Getting used items using the core service

  1. It’s worth noting that these are in the *Tridion.ContentManager.CoreService.Client* namespace (rather than having to reference the (internal) *Tridion.ContentManager.Data.dll*, as mentioned in the CHM documentation for the *UsedItemsFilterData* and *UsingItemsFilterData* classes.).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>