Issue in FindElementsByTemplate with searchRoot option

Discussion created by jagadeesh.macherla on Jul 16, 2012
Latest reply on Sep 20, 2017 by Kenji Hashimoto

Hello Team,


I am using the below code to get the element information...


AFElement searchRoot = null;
if (!string.IsNullOrEmpty(rootNode))
          searchRoot = this.Database.Elements[rootNode];   //AFElement root
           AFNamedCollectionList objAFElementCollection = new AFNamedCollectionList();
           if (this.Database.ElementTemplates.Contains(elementTemplateName))
                        objAFElementCollection = AFElement.FindElementsByTemplate(this.Database, searchRoot, this.Database.ElementTemplates[elementTemplateName], true, AFSortField.Name, this.Order, maxCount);


Here searchRoot is working at first level only...I mean it's only returning the information for the child element not for subchilds.


Note : This code is working fine if searchRoot is null. As per our requirement, we need to find all the element information(child as well as subchilds) based on template which is laying below the root.




Please assist us on this.