I have a form that has a few sections that are visible only when certain previous dropdown selections were made. As my form is now, someone could make a selection to make a section appear, fill out fields in the section, then go back and change the dropdown selection and the values stay in the fields that are now no longer visible. These values could mess with my automations downstream, so they need to be null if they are not visible. How can I ensure that fields retain a null value if they are not visible?
I'm a developer with Cognito Forms. In order to make sure that a field retains a null value even when changed from visible to not visible, what you can do is add an if/then statement to the default value of the field that you would like to clear the value from.
In order to do this, you'll select the field that you want to clear the value from when hidden. In the 'Default Value' found in the field settings, you'll create an if/then statement that is referencing the choice field and the selection within the choice field that its appearance is dependent upon. For example:
=if (ChoiceField="Choice") then null else null
Now, when someone makes a selection other than "Choice" in ChoiceField, the conditional field will disappear, and the value will be cleared.