Documentation Center

Filtering the result of GetListItems()

The GetListItems() and GetItems() methods takes an optional filter parameter to filter the list of items it retrieves.

The filter class is a subclass of Tridion.ContentManager.StronglyTypedFilter, and is different depending on the class from which you call GetListItems(). You can filter the returned DOM document or objects by setting properties on the specific filter object. These properties again depend on the class from which you call GetListItems().

Filtering items using properties

To create a filter, examine the properties available for your filter and set them to values that restrict your returned items. For example, the following code applies a filter to the returned items so that they only contain Components by setting the ItemTypes property:

OrganizationalItemItemsFilter filter = new OrganizationalItemItemsFilter(engine.GetSession());
filter.ItemTypes = new ItemType[] { ItemType.Component };

Here are some examples of properties:

ItemTypes
In the ItemsFilter class and its subclasses, specifies the type(s) of item you want to see. You can set its value to one of the following predefined constants:
  • If the container is a Publication:
    • ItemType.Folder (returns the root Folder)
    • ItemType.StructureGroup (returns the root Structure Group, if present)
    • ItemType.Category (returns all top-level Categories, if any exist)
  • If the container is a Folder or a Virtual Folder:
    • ItemType.Folder
    • ItemType.Schema
    • ItemType.Component
    • ItemType.ComponentTemplate
    • ItemType.PageTemplate
    • ItemType.TargetGroup
    • ItemType.TemplateBuildingBlock
    • ItemType.VirtualFolder
  • If the container is a Structure Group:
    • ItemType.StructureGroup
    • ItemType.Page
  • If the container is a Category:
    • ItemType.Category
    • ItemType.Keyword
LockFilter and LockResult
Causes only those items to be returned for which the item's LockType property equals LockResult after the LockFilter bitmask is applied.
SchemaPurposes
Causes only those items to be returned that are of the specified type(s) of Schema:
Schema typeDescription
BundleDefines the Process Definition and metadata of a certain type of Bundle
ComponentDefines the structure of the data fields of a certain type of Component
EmbeddedDefines a structure to be embedded in another Schema
MetadataDefines the structure of the metadata fields of a certain type of Component
MultimediaDefines content and metadata for a certain type of Multimedia Component
ProtocolDefines the parameters of a transport protocol
RegionDefines the definition and metadata of a certain type of Region
TemplateParametersDefines the parameters of a Template Building Block in a Compound Template
VirtualFolderTypeDefines a certain type of Virtual Folder
ComponentTypes
In the ItemsFilter class and its subclasses, causes only those items to be returned that are of the specified type(s) of Component:
Multimedia
A Component that contains binary (multimedia) data; that is, a Multimedia Component
Normal
A Component that contains normal structured data; that is, a normal Component
TemplateTypeIds
Causes only those items to be returned that are of the specified type(s) of Template. You can specify which ID corresponds to which Template Type in the Content Manager configuration file (Tridion.ContentManager.config.xml, located in %TRIDION_HOME%\config\ ), but by default, the values are set as follows:
Template TypeID
CompoundTemplate4
AssemblyTemplate5
CSharpTemplate6
DreamweaverTemplate7

You can add new IDs to the configuration file to represent custom Template Types you define yourself.

BasedOnSchemas
In the OrganizationalItemItemsFilter, specify one or more Schemas to only return items that are based on the Schema(s).
Recursive
In the ItemsFilter class and its subclasses, set to true to also retrieve the contents of the subcontainers (and their subcontainers, and so on) of the container you are examining. For example, if you call GetListItems() from a Folder object that refers to a Folder named foo which itself contains a Folder bar, setting Recursive to true causes the call to retrieve items from bar also, while setting it to false causes the call to get items from foo only.

Filtering properties for each item returned by GetListItems()

Each item that the GetListItems() method returns has a number of properties, or columns. The columns returned are the columns specified in the following properties of the filter object:

  • BaseColumns is a property which you can modify.
  • IncludeAllowedActionColumns is a Boolean that specifies whether to include or exclude allowed action columns in the result.
  • IncludeRelativeWebDavUrlColumn is a Boolean that specifies whether to include or exclude the relative WebDAV URL of the items in the results.

The BaseColumns property

The BaseColumns property offers a number of simple values to retrieve the most commonly requested sets of item properties:

Id
Retrieves only the ID (that is, the Content Manager URI) of each item.
IdAndTitle
Retrieves the ID and title of each item.
Default
(default value if BaseColumns is left unspecified) Retrieves the following properties of each item:
IdThe ID (that is, the Content Manager URI) of the item
TitleThe title of the item
TypeThe type of the item, represented as an integer
ModifiedA timestamp indicating the moment when the item was last modified
IsNewA boolean that indicates whether item is new or not
FromPubA label indicating the originating Publication of the item, or the (translated) text "local copy". This property is used by the Content Manager Explorer GUI.
URLThe WebDAV URL of the item
MIMETypeThe MIME type of the item
IconThis property is used by the Content Manager Explorer GUI only, you can ignore it.
SchemaIdIf this is a Component, the ID (that is, the Content Manager URI) of the Schema on which this Component is based
Extended
Retrieves all the properties listed under the value Default, and in addition, the following properties:
DescriptionA description of the Schema, Target Group, Category or Keyword.
IsPublishedA boolean that indicates whether the item has been published to any destination or not
IsSharedA boolean that indicates whether the item is shared from another Publication, that is, whether it has been created in a parent Publication, or not
IsLocalizedA boolean that indicates whether the item has been localized from another Publication, that is, whether it has been created in a parent Publication and subsequently been localized in this Publication, or not
LockAn integer that indicates which type of lock, if any, is applied to this item
TrusteeThe Content Manager URI of the user who locks this item, if any
SubTypeThe subtype of this item. This property applies to Schemas, where it indicates the purpose of the Schema, or to Template Building Blocks, where it indicates the type of template (Dreamweaver, C#, .NET assembly, or a custom template type).
FileExtFor Multimedia Components, the file extension of the binary file contained in the Multimedia Component