I have a folder, which has subfolders and components.
For example, Main folder name as 030 Main
, which has subfolders with names:
100 mango
120 apple
150 cake
archive
not used
trash
There are also some components within 030 Main
.
Now I want to retrieve only the components which uses a specified schema from certain subfolders (in bold above):
100 mango
120 apple
150 cake
I don't need any components from archive
,not used
,or trash
nor the components within 030 Main
.
I tried something like below, first with a filter on the folder structure (I got tcm id's of archive
,not used
,100 mango
,120 apple
,150 cake
,and trash
).
Then I checked if the folder's tcm id matches 100 mango
, 120 apple
, or 150 cake
.
If this condition is true, I use a component filter to get all the components with specified schema.
But here in
var id
I'm still getting the components present inarchive
,not used
,trash
.
Please suggest may be the second filtering part is not working.
OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData
{
ItemTypes = new[] { ItemType.Folder },
Recursive = true,
BaseColumns = ListBaseColumns.Id
};
foreach (var id in client.GetListXml(folderUri, filter).Elements().ToList())
{
string so = id.Attribute("ID").Value;
Console.WriteLine(so);
if ((so == "tcm:229-38695-2") || (so == "tcm:229-149861-2")||(so == "tcm:229-149940-2")||(so =="tcm:229-149941-2")||(so == "tcm:229-149942-2")||(so =="tcm:229-149943-2")||(so =="tcm:229-149875-2"))
{
Console.WriteLine("i m in");
OrganizationalItemItemsFilterData filter1 = new OrganizationalItemItemsFilterData();
filter1.ItemTypes = new ItemType[] { ItemType.Component };
filter1.ComponentTypes = new ComponentType[] { ComponentType.Normal };
filter1.Recursive = true;
StringBuilder sb = new StringBuilder();
string QuestionTitle = string.Empty;
foreach (var idin in client.GetListXml(folderUri, filter1).Elements().ToList())
{
string compSchema = idin.Attribute("SchemaId").Value;
string compId = idin.Attribute("ID").Value;