Result
The result tag is used to reference values across templates.
Defining a result
If you want to reference a certain value from reconciliation template A in another template, it can be done with the so-called result tags.
The result name can be freely chosen, but should be unique for that template A. The content is the value or variable you want to reference to.
{% result "name" content %}
Let’s say we have stored a calculation of taxes in register $1 and we want to put it into a result tag. The code can look like this:
{% result "tax_calculation" $1 %}
Result tag in a loop
Result tags can be also used in a loop, to be able to reference the value of each loop in the result. In that case the name of the result tag needs to be different in each iteration.
To make sure the result tag is working correctly, remove the quotes around the name of the tag, i.e. {% result name content %}.
For more information, please see the case on the Developer Community.
Accessing a result
If we make the assumption that the handle of template A is template_a (handles make each template unique, and we need it to tell the templating language what template we need to reference from), the code to retrieve the result value from template A, where our tax calculation is stored, would look like this:
{{ period.reconciliations.template_a.results.tax_calculation }}
Pitfalls
-
Please note that a result tag cannot be used to reference to a variable that was made within the same template; result tags are only used to reference across different reconciliation templates.
-
Circular references should not be made. Circular references occur when template A calls a result value from template B, while template B references a result value from template A.
-
Please note that there is no need to make result tags for input-objects, since their values are stored in the database. You can reference to them with {{ period.reconciliations.template_a.custom.some.variable }}. This is easier to code, makes your code cleaner and leads to better results performance wise.
-
When using results across templates, it's important to keep in mind the three level dependency limitation. If you exceed this limitation, you may encounter cache issues.
-
Results are generated in the so-called "Input View". For this reason, it is important to avoid having any result (but also any calculation that will affect a result) inside ic or nic tags. If not, discrepancies in the result may occur, leading to potential cache issues. (only for account templates)
Updated almost 2 years ago