You need to sign in to do that
Don't have an account?
Sam Mohyee
List all accounts below parent account in hierarchy
It's easy enough to write a SOQL query to pull all the immediate child accounts of a given account. But what if I want the children's children, etc, all the way to the 'leaf' accounts (the children that have no children)?
Is there an existing method provided by Salesforce that would return this when given an Account ID?
If not, I figure recursion is the way to go, assuming Salesforce permits it. Something along the lines of this pseudocode
list_build_function (account ID){ Query all children accounts; Put IDs in child_ID_lis Add IDs onto full_ID_list; for (each ID in child_ID_list){ list_build_function(child ID);
}
}
Yep, i guess thats the only way, you cannot go more than one level deep in soql query