Conditional Logic on Forms
Welkin’s Form Designer supports conditional logic to show and hide fields on forms. To use this functionality, the sections, questions and answer fields must be added to the form first. Once all of the questions and answer fields have been added, go to the “Conditions” tab within the form configuration to add your show/hide logic.
In the following scenario, I want to show a question “Enter LMP” or “Enter EDD” based on which date type will be used to calculate the gestational age.
Condition logic needed:
If date type = LMP then show “Enter LMP” question
If date type = EDD then show “Enter EDD” question
Steps to configure the conditions for the scenario above:
- Go to the “Conditions” tab in the form configuration.
- Click “Add Element”.
- Choose the section of the form where the fields you want to show/hide are located
- Choose the field you want to show/hide (for scenario above FIeld #2).
- Choose the condition(s) that need to be present to “show” the field in Step 4 above – Click “Add Condition” within Element #1.
- Add the conditional logic needed to show the question/answer field “Enter LMP” (gestational-age-calculation: enter-date).
- Explanation of the configuration above (Element #1):
- In Section = Gestation age calculation show Field #2 (gestational-age-calculation: enter-date) if Field #1 (gestational-age-calculation: date-type) = LMP
- Set up another Condition Element for the “Enter EDD” question.
- Explanation of the configuration above (Element #2):
- In Section = Gestation age calculation show Field #3 (gestational-age-calculation: expected-delivery-date) if Field #1 (gestational-age-calculation: date-type) = EDD
- NOTE: Operation “And” includes all conditions (if there are multiple), Operation “Or” includes any of the conditions (if there are multiple)
- Outcome of the configuration for conditions in the form. Questions for Enter LMP and Enter EDD are hidden until the conditions are present to show them:
- When date type = EDD
- When date type = LMP