Alternative to getAccountByName()
I need to get / lookup an account by its system ID/Key (I assume it has one?). I can only find getAccountByName(). There is a getAccountNum() but it says 'don't use this, it's stupid'. I can't see that looking up by a text name is 'safe'. For example, I have two account with the same name (for testing). Please advise how to return an Account's 'key' and the correct method to then lookup the Account using that key? Many thanks
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
1 Posted by Mike Bray (Quot... on 01 Oct, 2020 07:50 AM
Use AccountBook.getAccountByUUID(String acctID). Moneydance changed the
numbering system I think in version 2015, the getAccountNum() is for
accounts created before. All records within MD have a UUID which is in
the SyncableItem class which all records extend. Account.getUUID()
returns the account's UUID.
2 Posted by Stuart Beesley ... on 01 Oct, 2020 07:52 AM
Thanks Mike, that make sense. But now given that I have an Account’s UUID, is there a method I can call to retrieve the account?
So if I know that an Account’s UUID is 123; can I call .getAccountByUUID(123) to return the account? I cannot find such a method?
THanks
3 Posted by Stuart Beesley ... on 01 Oct, 2020 08:00 AM
I think I found it....:
AccountUtil.findAccountWithID(Account root, java.lang.String accountUUID)
Can someone confirm this is OK in conjunction with AccountBook.getAccountByUUID(String acctID).?
(I'm learning that in the API Docs you need to look at the inherited Methods section too!)
4 Posted by Stuart Beesley ... on 01 Oct, 2020 10:14 AM
I've confirmed this works. Thanks
Stuart Beesley (Mr Toolbox) closed this discussion on 01 Oct, 2020 10:14 AM.
Mike Bray (Quote Loader Author) re-opened this discussion on 01 Oct, 2020 01:10 PM
5 Posted by Mike Bray (Quot... on 01 Oct, 2020 01:10 PM
It is on the AccountBook as per my post
Support Staff 6 Posted by Sean Reilly on 01 Oct, 2020 03:11 PM
As Mike says, the AccountBook.getAccountByUUID() method is the one to use. If you'd like a permanent reference to any kind of object you can also use the objects .getUUID() method, and use AccountBook.getItemForID(String uuid) to retrieve it again.
Cheers,
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
Maddy closed this discussion on 02 Oct, 2020 12:05 PM.