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?
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())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With