CommCare – Difference Between Default Value and Calculate Condition

commcare

When making a hidden value question and filling in the Default Value with a question, CommCare gives me a warning.

enter image description here

What is the difference here between Default Value and Calculate condition? And why would a Default Value that references a question cause an error?

Best Answer

Great question! You seem like a swell dude.

The main difference between a calculate condition and default value is when the calculation will occur. Specifically, a default value will only be set once immediately upon opening the form. This is used primarily to load static values like case and session properties into the form.

Meanwhile, a calculate condition will fire multiple times during form entry (including at completion) so that its value always reflects the current state of the form accurately. This should be used for most purposes as calculates will be re-calculated based on answers given in the form.