CASE reference values across templates by using result tags

If you want to reference a certain value or variable from recon template A in another template, there’s a way to do it with the so-called result tags in STL.

They work like this (:bulb: just type in result and press TAB to get this preformatted code :bulb:):

{% result 'name' content %} 

where the name is a shortname you can choose, and the content is the value or variable you want to reference to.

Let’s say we have this variable done_prepayments in our recon template Prepayments (which is also taken into a register $1 for further calculation):

{% =$1+ done_prepayments %}

This value needs to be taken into a result-tag, because it needs to be displays in another template.
We can by doing this:

{% result 'done_prepayments' $1 %}  OR {% result 'done_prepayments' done_prepayments %}

The place where you put this, doesn’t matter most of the times but I’d suggest adding this next to the variable or object you reference to:

{% =$1+ done_prepayments %}  {% result 'done_prepayments' $1 %} 

Handle of a recon template

There’s one condition that needs to be fulfilled if you want to reference to values from reconciliation templates: the recon template needs to have a handle!
you can find this on firm level, if you click on the recon template:
55

The handle makes each template unique, and we’ll need it later on so tell STL what templates we need to reference from (so we won’t use the name of a template, but the handle).

Reference in another template

Let’s display the result in another template; we’ll define that like this:

{{ period.reconciliations.prepayments.results.done_prepayments | currency }} 

so, {{ period.reconciliations.handle.results.result_tag_name }}

period: we do need to access the current period
reconciliations: to tell Silverfin to look at the recon templates
handle: of course we need to know which recon template, and we use the handle for that (unique for every recon template!)
results: this way, Silverfin will only read the result tags of that particular template
result_tag_name: the name of the specific result tag (done_prepayments)

:mega: :mega: Precautions :mega: :mega:

You should know that within the same template, you can not use a result tag to reference to a variable that’s been made within that same template; result tags are used only to reference across different recon templates.

Example:

{% fori stock in custom.stocks %}
  {% $1+input stock.value %}
{% endfori %}

Value stock: {{ $1 | currency }}  {% result 'stock_value' $1 %} 

when you create a fori-loop that’s filled with data, and a value is calculated from that data. Notice that we take that value into a result-tag.

Let’s say the year after, that same template needs to show the value of previous year.

:x: This cannot be done: :x:

Value stock last year = {{ period.minus_1y.reconciliations.stocks.results.stock_value | currency }}

The reason for this is performance, where you make templates that much harder to load if they need to look at previous periods as well (picture calling on results from the last 5 years: that means the template will need to load 6 times!)
If above is done, following error will be displayed:
35

How to call on that result then from a previous period?

You’ll have 2 options:

  1. recalculate the value of previous period

You can easily call on that custom collection from previous period (with all the data in it), as such data is stored directly in the database of the client file (therefor, no loading needed at all as it calls on that data directly from the datasbase):

{% comment %}recalculate values of previous year{% endcomment %}
{% for stock in period.minus_1y.reconciliations.stocks.custom.stocks %}
  {% $10+ stock.value %}
{% endfor %}

{% assign stock_value_1y = $10 %}

Value previous year stock = {{ stock_value_1y | currency }} 
  1. use the rollforward tag

As explained here, you could use the rollforward tag, where certain data is rollforwarded into another variable or object when an user copies details:

:mega: :mega: Precautions :mega: :mega:

Also, you should try to avoid circular references!
F.i. if you want a result from template A to reference in template B, but template B want to reference something from template A. This won’t work at all; a proper error in the working papers will appear like this:
14

To avoid such circular references, it’s better to have one template where all values are made, and use that template to reference from to all other templates.
Also, if you want to reference to an input-object (like above), then it’s easier to simply avoid the result tags but access that object directly. Because it is stored on the database locally of the client file, you could access it better this way:

{{ period.reconciliations.prepayments.custom.done_prepayments.value | currency }} 

so,
period.reconciliations.prepayments: to look at the needed template
custom.done_prepayments.value is the name of the database object.

It’s even better for the performance for the loading of the working papers: Silverfin needs to load all result tags first. If some of those can be accessed directly to the input objects, it will load faster.

1 Like