Can you replicate the issue on our v5 demo site? Yes.
Have you searched existing issues? Yes.
Describe the bug
All variables are empty or do not exist when used with twig.
Steps To Reproduce
Create a new invoice template.
Select an invoice.
Paste this twig code into the header:
<ninja>
{% if client.name != "" %}
exists
{% else %}
does not exist
Test: $client.name
{% endif %}
</ninja>
Expected Behavior
“exists” should come out on the invoice preview.
But instead, “does not exist” and the client name comes out.
Thank you for your help.
Edit:
My fault. You need to get the first invoice object first like here:
<ninja>
{% set var = invoices | first %}
{% if var.client.name != "" %}
exists
{% else %}
does not exist
Test: $client.name
{% endif %}
</ninja>
Is it possible to access the variable client.name without setting the var variable first?
The documentation confused me, because it says that you can access invoiceninja variables, too:
If I understand the “architecture” of this variable-system correctly it’s part of a big mapping. This is something like arrays of variables but the single array-values have a further value or even array or mapping. You can compare this with a file-system-tree: