Is it possible to sort/order the collection of accounts on a custom value?
Similar to sorting account details on e.g. the date:
{% assign details = current_account.details | sort:‘date’ %}
Or similar to sorting accounts on name
{% assign sorted_accounts = period.accounts | sort:'name %}
Something like the code beneath does not seem to work
{% assign sorted_accounts = period.accounts | sort:‘custom.foo.bar’ %}
Is there a way to achieve this?
This is indeed not possible at the moment. I’ll have a look what I can do for you.
Kind regards
Hi Robin
This works:
{% addnewinputs %}
{% assign details = current_account.details | sort:"custom.bla" %}
{% endaddnewinputs %}
{% fori detail in details %}
{% input detail.custom.bla %}
{% endfori %}
Are you something with this? If not, could you let us know why you want to add a custom variable to an account?
Kind regards
Hi Sam,
Thanks for this, but it does not provide the functionality that we desire.
We want to sort the accounts themselves in an account collection, not their details (at least not for we are asking here, we do want this in other places, where we are able to achieve this successfully with similar code to what you posted).
We use the custom drop on an account in many places, for many different purposes.
This is also documented in the github page (https://github.com/GetSilverfin/sf-templates/blob/master/drops/account.md):
custom drop A way to attach custom information to the account for the current period
The Silverfin account templates use this custom drop on the account as well, to store information that is applicable to the entire account and not on specific details of it.
For example in the template ‘Leningen & Leasingen’: custom.lening.ontlener, custom.lening.doel, custom.lening.rentevoet, custom.lening.duur, custom.lening.ontleend bedrag (total loan amount) etc. are used like this.
We would like to use the values in these custom drops in reconciliation templates to sort the accounts that were selected through an input into an account collection, e.g. to order them by total loan amount.
Does this make sense?
Hi Robin
Sorry for the late response. This is not possible at the moment.
Hopefully you’re not too disappointed.
Kind regards
Sam
Well, we kinda are…
We’ve implemented a devious workaround in Liquid to achieve the required ordering by ourselves by now though.