Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BasedOnSchemas option in Tridion 2011 CoreService

I'm trying to understand the purpose of the BasedOnSchemas option in the OrganizationalItemItemsFilterData filter.

The documentation clearly states: "Gets or sets the BasedOnSchemas condition to return only items that are using the given schemas" So it should be possible to only retrieve components of a specific schema, right?

here's my code:

LinkToSchemaData[] schemaLinks = new[] { 
        new LinkToSchemaData { IdRef = "tcm:113-362325-8" } 
    };

OrganizationalItemItemsFilterData filter = 
    new OrganizationalItemItemsFilterData();

filter.BaseColumns = ListBaseColumns.Extended;
filter.ItemTypes = new ItemType[] { ItemType.Component };
filter.Recursive = true;
filter.BasedOnSchemas = schemaLinks;

XElement items = client.GetListXml("tcm:113-14192-2", filter);

The XElement items will however, contain multiple types of components, not only those of schema tcm:113-362325-8

How can I retrieve only those components that are based on my schema?

like image 485
Reinder Wit Avatar asked Aug 28 '12 08:08

Reinder Wit


1 Answers

Using both BasedOnSchemas and Recursive = true is not supported. Remove the the recursiveness and you'll find that the schema filter works.

If you want to get a "recursive" list of all Components for a certain Schema, consider doing a WhereUsed on the Schema.

GetListXml("tcm:5-59-8", new UsingItemsFilterData())
like image 195
Frank van Puffelen Avatar answered Dec 12 '22 11:12

Frank van Puffelen