What I want to do: I want to assign a variable with the value of another variable, however if something is filled out in an input box this value should used.
Default values are assigned here (and always correct):
{% assign city = company.city | remove:"1" | remove:"2" | remove:"3" | remove:"4" | remove:"5" | remove:"6" | remove:"7" | remove:"8" | remove:"9" | remove:"0" | remove:"bus" | remove:"Bus" | remove:"BUS" | strip %}
{% assign end_by = period.year_end_date | date:"%d/%m/%Y" %}
Defaults are overloaded using assign and default:
{% assign document_city = custom.statement_annual_accounts.document_city | default: city %}
{% assign document_date = custom.statement_annual_accounts.document_date | default: end_by %}
Input look like this (note that the defaults are -as expected- visible as placeholder):
{% input custom.statement_annual_accounts.document_city as:text placeholder:city %}
{% input custom.statement_annual_accounts.document_date as:date required:true format:'%d/%m/%Y' placeholder:end_by %}
Test code to see the result
{test-)
{% if custom.statement_annual_accounts.document_city != blank %}
document_city "{{ custom.statement_annual_accounts.document_city }}"
{% else %}
city {{ city }}
{% endif %}
Result: {{ document_city }}
{% if custom.statement_annual_accounts.document_date != blank %}
document_date "{{ custom.statement_annual_accounts.document_date }}"
{% else %}
end_by {{ end_by }}
{% endif %}
Result: {{ document_date }}
(-test)
When I look at the default view the output is correct:
However in the export (or previewing, or rendering the preview as Excel) the values are empty.
Even if the values are filled out in the inputs the result remains empty when not in preview.
Using an alternative to the default
results in the same issue
{% assign document_city = city %}
{% if custom.statement_annual_accounts.document_city != blank %}
{% assign document_city = custom.statement_annual_accounts.document_city %}
{% endif %}
{% assign document_date = end_by %}
{% if custom.statement_annual_accounts.document_date != blank %}
{% assign document_date = custom.statement_annual_accounts.document_date %}
{% endif %}
How can this be resolved?