tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/3602-api-getpreferredsortorder-etc-does-not-seem-to-workInfinite Kind: Discussion 2020-11-24T07:06:29Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/488262382020-11-17T10:16:15Z2020-11-17T10:16:15ZAPI .getPreferredSortOrder() etc does not seem to work?<div><p>??</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/488262382020-11-24T07:06:24Z2020-11-24T07:06:24ZAPI .getPreferredSortOrder() etc does not seem to work?<div><p>Sean has replied:</p>
<p>You're on the right track! The UI preferences for an individual account are stored in a string which is an encoded com.infinitekind.tiksync.SyncRecord object. As you discovered, the preferences key is col_widths. where is one of bank, cc, loan, invest, secdetail, or misc. To get the settings for a specific account you can call String prefString = account.getPreference(preferencesKey, null) . If the return value is null or an empty string then you can call prefs.getSetting(preferencesKey, null) where prefs is an instance of the moneydance app UserPreferences object, which I'm guessing you've probably already found. The resulting string value, if any, will be an encoded SyncRecord object which you can get by calling SyncRecord params = new SyncRecord(); params.readSet(new StringReader(prefString)) at that point you have the UI preferences for the account (or for the type of register, as a fallback) in the SyncRecord which is a handy way to access the multiple details. For the sort order and ascending/descending status you can use:<br>
boolean ascending = params.getBoolean("ascending", true); TxnSortOrder sortID = TxnSortOrder.fromInt(params.getInt("sort", -1), ascending) TxnSortOrder is a public enum in the com.infinitekind.moneydance.model package and has all of the currently supported sort orders.</p></div>Stuart Beesley (Mr Toolbox)