Unsafe variable

We now get a message to improve our code when we safe a template. But I’m now getting the message “Unsafe variable names detected: custom[current_account.number].dagen_in_jaar”. Fine but the problem is that I don’t know why it’s not correct and what do I have to take into account to correct this? I’ve a similar variable “custom[current_account.number].manueel” where I don’t get an warning message.

Can anyone explain me the difference?

Goodmorning Peter,

Can you please share the code where those two variables are assigned?

Best regards,

Michiel

Hi Michiel, here’s a part of the code because all the code is to much (adaptation of the intrest calculation) and spread over 7 parts. This is the only place where these 2 variables are mentioned.

{% capture keuzetabel %}
|--------------------------------|----10%--|----15%----:+
| **{{ current_account.link }}** | {% ic %}{% input custom[current_account.number].manueel as:select options:rc_types  default:'maand' option_values:'dag|maand|kwartaal|jaar' %} | {% if custom[current_account.number].manueel=='dag' %} {% t "Dagen" %}: {% input custom[current_account.number].dagen_in_jaar as:select options:noemer_types  default:1 option_values:'1|365|360' assign:noemer %}{% endif %}{% endic %}{% ic %}|{% endic %}
{% endcapture %}

{{ keuzetabel }}
{% assign custom[current_account.number].dagen_in_jaar = noemer %}
{% if current_account.asset_or_expense %}
  {% assign multiplier = 1 %}
{% else %} {% assign multiplier = -1 %}
{% endif %}

Hi Peter,

The problem is following code: {% assign custom[current_account.number].dagen_in_jaar = noemer %}

You can never assign a custom variable like this. Custom variables can only be filled in by using {% input custom[current_account.number].dagen_in_jaar %} and enter the value in your template. Based on the piece of code you shared, I tend to say that you can use a local variable instead of a custom variable

Regards,
Michiel

Thanks Michiel,

I’ve removed the assign part because this had no use anymore and everything is OK now.