CASE: check if another reconciliation exists with the exists? method

When you want to link to another reconciliation (a linkto eg), you always need to check if that reconciliation is added in the company file (ergo if it exists or not). If not, this could lead to Liquid errors being shown in your template, which is to be avoided at all costs (obviously).

This can be done by the so-called exists? method on the reconciliation drop. Here’s a case to have something like this:

Here’s the code to get just that, in which an important coding guideline stands out: always check if something exists if you want to access it :bulb:

{% comment %}create needed vars{% endcomment %}
{% assign fixed_assets = period.reconciliations.vaste_activa %}
{% comment %}check if the recon exists or not{% endcomment %}
{% assign show_fixed_assets = false %}
{% if fixed_assets.exists? %}
  {% assign show_fixed_assets = true %} 
{% endif %}


{% comment %}display info header with link to the FIXED ASSETS reconciliation{% endcomment %}
{% if show_fixed_assets %}
{% ic %}{::infotext}
Numbers are directly taken from the reconciliation {% linkto fixed_assets %}{{ fixed_assets.name }}{% endlinkto %}.
{:/infotext}{% endic %}
{% endif %}

An overview of other methods on that specific reconciliation drop.