svalais
February 11, 2021, 2:44pm
1
Hello,
We have a problem with following code:
Blockquote
{% stripnewlines %}
|
|
|
|
[{% newline %}
|
] {% t “Compliance check” %}
|]
|] {% t “Compliance Consultant/Manager - Confirmation” %}
|] {% t “Compliance expert – Ready for client validation” %}
[{% newline %}
|
] {% t “Accountancy aandachtspunten” %} {% input period.custom.accreview.tax.file as:file %}
|] {% t “Reactie” %}
|]
|]
[{% newline %}{% assign $1 = 1 %}{% fori accreview in custom.accountancy_review %}
|] {{ $1 |integer }}. {% input accreview.vraag as:text placeholder:‘’%}
|] {% ic %}{{ $1 |integer }}.{% endic %} {% input accreview.antwoord as:text placeholder:‘’%}
|] {% ic %}{{ $1 |integer }}.{% endic %} {% ic %}{% input accreview.vraag_check as:boolean %}{% endic %}{% if accreview.vraag_check == true %}{{ accreview.vraag_check.updated_by.name }} {{ accreview.vraag_check.updated_at | date:“%d/%m/%Y” }}{% endif %}
|] {% ic %}{{ $1 |integer }}.{% endic %} {% ic %}{% input accreview.antwoord_check as:boolean %}{% endic %} {% if accreview.antwoord_check == true %}{{ accreview.antwoord_check.updated_by.name }} {{ accreview.antwoord_check.updated_at | date:“%d/%m/%Y” }} {% endif %}
[{% newline %}{% assign $1 = $1+1 %}{% endfori %}
{% endstripnewlines %}
Blockquote
When the checkbox for third column is checked and a user checked the checkbox in the fourth column, then the name and date of the third column is changed in the name and date of the fourth column.
Is it possible to have a quick look to this problem?
Thanks a lot,
Sylvie
Hi Sylvie,
This is a known challenge as from the technical point of view the updated_by
and updated_at
methods can only be call once per loop iteration, that means that the date and time will keep updating when you click the booleans (previous shown date/times are not kept in our database and that’s why the second column is being overwritten).
There is a workaround for this though. You can create a custom variable that does not belong to the collection of the loop itself but it’s linked to it indirectly with the key, for example: custom.test.[accreview.key]
. This variable name will change dynamically because of the key but it doesn’t belong to the custom.accountancy_review
collection so that you can keep two separate records for the dates.
Please see the below code as an example:
{% stripnewlines %}
|
|
|
|
[{% newline %}
|
] {% t “Compliance check” %}
|]
|] {% t “Compliance Consultant/Manager - Confirmation” %}
|] {% t “Compliance expert – Ready for client validation” %}
[{% newline %}
|
] {% t “Accountancy aandachtspunten” %} {% input period.custom.accreview.tax.file as:file %}
|] {% t “Reactie” %}
|]
|]
[{% newline %}{% assign $1 = 1 %}{% fori accreview in custom.accountancy_review %}
|] {{ $1 |integer }}. {% input accreview.vraag as:text placeholder:’’%}
|] {% ic %}{{ $1 |integer }}.{% endic %} {% input accreview.antwoord as:text placeholder:’’%}
|] {% ic %}{{ $1 |integer }}.{% endic %} {% ic %}{% input accreview.vraag_check as:boolean %}{% endic %}{% if accreview.vraag_check == true %}{{ accreview.vraag_check.updated_by.name }} {{ accreview.vraag_check.updated_at | date:"%d/%m/%Y" }}{% endif %}
|] {% ic %}{{ $1 |integer }}.{% endic %} {% ic %}{% input custom.test.[accreview.key] as:boolean %}{% endic %} {% if custom.test.[accreview.key] == true %}{{ custom.test.[accreview.key].updated_by.name }} {{ custom.test.[accreview.key].updated_at | date:"%d/%m/%Y" }} {% endif %}
[{% newline %}{% assign $1 = $1+1 %}{% endfori %}
{% endstripnewlines %}
Let us know if you have any questions.
Best,
Borja
svalais
February 12, 2021, 7:13am
3
Hi Borja,
Thanks for the answer but what happens with the already checked checkbox with this update?
Are the data lost?
Thanks a lot,
Sylvie
svalais:
accreview.antwoord_check
Hi Sylvie,
The data is not lost, it’s still stored in accreview.antwoord_check
so you could perhaps show it as a default. Something like this:
{% input custom.test.[accreview.key] as:boolean default:accreview.antwoord_check %}
The only problem with the above is that the boolean might be ticked by default but you still have the issue regarding the date.
Best,
Borja