CASE: create account collection with only starred accounts possible

Let’s examine the code of a reconciliation template, which let you select a range of accounts that have certain details in it:

{% input custom.accounts.numbers_42 as:account_collection range:"4,17" accounts_var:accounts_42 %}

Perhaps we want to change the possibility to select all accounts in that range and change it in accounts in that range that are starred?

With the method .starred we can however:


This will actually give you all accounts in the current period that are starred.

Let’s change our code so it can give only starred accounts in a certain range:

{% comment %}create starred range for range 4 & 17{% endcomment %}
{% assign standard_range = "4,17" %}
{% assign starred_range = period.accounts[standard_range].starred | map:"number" | join:","  %}

{% input custom.accounts.numbers_42 as:account_collection range:starred_range accounts_var:accounts_42 %}

Let’s examine this:

{% assign standard_range = “4,17” %}
{% assign starred_range = “” %}

We create 1 variable to filter later on the period.accounts drop

{% assign starred_range = period.accounts[standard_range].starred | map:“number” | join:"," %}

We loop over all accounts that are in the range of 4,17 and also are starred (you can read it like period.accounts[“4,17”].starred)

The map filter will take each element ( = number ) of the already filtered drop period.accounts[standard_range].starred and join each element with a “,” so we get something like this for instance:


This string now can be used in our account collection:

{% input custom.accounts.numbers_42 as:account_collection range:starred_range accounts_var:accounts_42 %}

Updated the case with the much easier map filter: lesser, easier code is what we strive for! :ok_hand: