Caluclation ereasing data entry

Hello,

I have a form where I want to preselect the data based on inputs but I want the user to be able to change the value (initial expression approach)

but it seems that upon form submission the calculation are erasing the data entered by the user

is there a way to prevent this behavior and have the calculation running only once ?

thanks in advance

example of the calculation, case are defined based on context vars

if(${_case_date_vat4}!='','4', if(${_case_date_vat3}!='','3', if(${_case_date_vat2}!='','2', if(${_case_date_vat1}!='','1' ,''))))

br

What version of the CHT are you using?

I have not tested this, but off the top of my head, I wonder if using the coalesce function in your calculation would work.

coalesce(., if(${_case_date_vat4}!='','4', if(${_case_date_vat3}!='','3', if(${_case_date_vat2}!='','2', if(${_case_date_vat1}!='','1' ,'')))))

I think think this would always keep the current value (.) unless it is empty (so would not work if the user needs to be able to clear the value…).

1 Like

Thank you it worked well,

I was afraid of the cyclic redundancy issue by testing it but it did not happen

br

2 Likes