Depth of getSubAccounts()
getSubAccounts(AcctFilter search)
is documented as follows:
Return a list of all accounts under this account matching the given filter. This includes accounts not just direct children but all accounts under this one in the hierarchy.
It's very reasonable that a filtered query would search the entire tree.
getSubAccounts
also has a parametrerless overload, which lacks any explicit documentation. As a developer, I'm not confident whether or not the parameterless version will also return all children throughout the hierarchy, or if it will only include immediate children. In my experience, I have seen both approaches to hierarchy APIs.
I experimented on my own, and ended up finding that the parameterless getSubAccounts
does indeed only return direct children.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Sean Reilly on 02 Jun, 2020 09:57 AM
Hi Max,
As you discovered, the parameter-less getSubAccounts() does only ever return immediate sub-accounts. The getSubAccounts with the filter parameter basically calls through to the AccountUtil.getAccountIterator(...) method. In general, I'd recommend using the AccountUtil.* static methods for querying accounts and account hierarchies. I think those make it a little more explicit what it is that is returned.
Thanks!
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
Support Staff 2 Posted by Sean Reilly on 02 Jun, 2020 10:02 AM
I've also updated the documentation on getSubAccounts(). Thanks for the note!
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
Max Pixel closed this discussion on 11 Jun, 2020 05:34 AM.