Rules are set in the top Form element. They determine which parts of the form will be shown to the user, depending on the selection the user does.
In order to create a rule, you must first create the elements you want to use in that rule. When that is done, the rule is defined in the Form element. In these pictures we show a medical report where we have created the questions Gender and Pregnant. We have checked the property Hidden as default for the Pregnant element, as we want to only show this question to female respondents.
- Click on the Form element at the top so this is selected.
- Go to the Rules tab in the Element Properties, and press [Add] to add a new rule.
- In the Zegeba Rule Editor, first write a name for the rule. We will call our rule Pregnant.
- Design the rule formula by first selecting an operator and dragging it to the left IF pane. Here we have chosen “=”:
- Then go to the Form Elements tab and drag the element you wish to specify the value of to the top yellow field of the operator. In our case this is Gender:
- Define in the left pane what you wish the value of the selected element to be compared to. We want the gender to be “female”, so we pull the [Text/String] operator to the left, below ‘=’, click and type in female. (Note that you should not drag the element “gender/female” to the IF box, but specify the value “Female” as a response to the gender question.)
- Then specify what should happen if the condition is fulfilled by dragging actions and form elements to the THEN DO pane. For our medical report we want to show females our question regarding pregnancy. From the tab Rule Logic we drag the action Show to the left.
Then we drag the element pregnant from the tab Form Elements into this.
Thus, our rule Pregnant defined in the top Form element makes the form show the question regarding pregnancy to only female respondents.
Note that the name of the rule is referenced in the Rules tab of the elements it mentions, in Related Rules. You can click on the rule here to access it.
Note! If you change the name of an element referenced in a rule, you will be asked if you would like to update the references to this element with the new name.
- To compare two values, first drag the Operator to the left pane, then the Form Elements and/or the Values.
- To compare with a specific value, use [Text / String] to enter the value.
- To change comparison logic, element or value, click on the item in the left pane to select other items.
Note! The logic in Rules defined on the top Form element has an IF… THEN structure. The logic in Validations defined on random elements has an IF NOT… THEN structure, as explained in Designing: 5.2 Calculation and validation.
See also Designing: 5.4 List of functions.