Skip to main content
2 of 5
added 1959 characters in body

retrieving component from subfolders excluding some subfolders

I have a folder, which has subfolders and components.For example Main folder name as 030 Main, which has subfolders with names archive,not used,100 mango,120 apple,150 cake,trash and some components within the 030 Main. Now i want to retrieve only the components which uses a specified schema from only subfolders 100 mango,120 apple,150 cake.(i.e don't need any components from archive,not used,trash and components within the 030 Main.) Tried something like below, First had put filter on folder structure(i got tcm id's of archive,not used,100 mango,120 apple,150 cake,trash) then checked for condition if folder tcm id is (100 mango,120 apple,150 cake). Then iff condition is true put component filter and get all the components with specified schema, but here in "var idin " still getting the components present in archive, 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;