When using forms in your processes it can sometimes be useful to change form field settings depending on previous selections or inputs in the form. Rules editor makes it easy to change if a field is optional or not, hidden or shown or if it is enabled or disabled according to conditions depending on previous inputs i the form.



Add form rules

  1. Open your form and click on the Form rules icon in the upper menu



  2. Click on Add new rule

  3. Select a form field, a condition (see all conditions below) and, if requested, a compare value.



  4. State the action by selecting a second form field and choose an action for that field (see all available actions below)



  5. If desired, add more actions.

  6. Click on OK.


NOTE: 
When adding rules for a form field, note that the opposite action will apply if the condition of the rule is not fulfilled. I.e. if you have a rule saying that a form field should be enabled if a condition is fulfilled, then if not fulfilled the field will be disabled.


Available conditions

  • Is equal to - Use for comparing exactly with the compare value
  • Is not equal to - Use to make sure the value isn't equal to the compare value
  • Contains - Check if the selected field contains the compare value
  • Does not contain - Check if the selected field does not contains the compare value
  • Starts with - Check if the selected field starts with the compare value
  • Doesn't start with - Check if the selected field does not starts with the compare value
  • Ends with - Check if the selected field ends with the compare value
  • Doesn't end with - Check if the selected field does not end with the compare value
  • Is empty - Check that the form field is empty
  • Is filled - Check that the form field contains information
  • Any of - Check that the selected field contains any of the compare values in the given comma separated list.
  • Not any of - Check that the selected field does not contains any of the compare values in the given comma separated list. 


NOTE: All available conditions do not apply to all kinds of field types. For example checkboxes can only be empty or filled. 


Available actions

  • Required - The form field will be mandatory to fill
  • Optional - The form field will be optional to fill
  • Hidden - The form field will be hidden
  • Hidden and Cleared - The form field will be hidden and emptied
  • Shown - The form field will be shown
  • Enabled - The form field will be enabled and can be edited
  • Disabled - The form field will be disabled and can't be edited


NOTE: A field that has a contradicting rule statement to the allowBlank = true/false attribute will always be considered optional/mandatory based on the attribute and not the rule. This is because the allowBlank attribute is always executed despite any form rules. 


On the other hand, any other attribute such as allowBlankInViewMode, hidden and disabled can be overridden by a contradicting form rule.


Edit or remove form rules

  1. Open the Form rules editor



  2. a) If you want to remove an entire rule and all its actions klick on the trash can to the right of the rule



    b) If you want to edit a specific rule, click on the pen symbol to the right of the rule, settings for the condition and the actions are shown. Edit as desired and click on OK to save the new settings.

  3. Click on Save.


TIP: You can also disable a rule if you like to pause its conditions and actions but not remove the setting totally. Click on the square symbol to the right of a rule to inactivate the rule.


Execution of form rules

Form rules are executed from top to bottom. We don't recommend configuring several rules that affect the same field with the same action/inverse action, since the last rule will be the one in effect.


This example clearly illustrates the issues:


A form contains a drop down field where the user is set to decide the number of options to make visible and fill in. There are three hidden sub-forms that represents three available options the user wishes to make available depending on the number selected in the drop down field. The three hidden sub-forms are shown in the picture below to illustrate but when running this form in a process application, none will be shown until a selection is made in the drop down list.


blob1477300107552.png


The user might try and configure the form rules like this in order to show the first form if 1 is selected, the first two forms if 2 is selected and all three forms if 3 is selected.


blob1477301175059.png
However, as mentioned earlier, all rules are validated from top to bottom and if a statement is not true then the opposite will be the default setting for the field meaning in this case:


numberOfOptions = 1


RULE1 is TRUE: hiddenForm1 will be shown

RULE1 is TRUE: hiddenForm2 will be hidden 

RULE1 is TRUE: hiddenForm3 will be hidden


RULE2 is FALSE: hiddenForm1 will be hidden

RULE2 is FALSE: hiddenForm2 will be hidden

RULE2 is FALSE: hiddenForm3 will be hidden


RULE3 is FALSE: hiddenForm1 will be hidden

RULE3 is FALSE: hiddenForm2 will be hidden

RULE3 is FALSE: hiddenForm3 will be hidden


RESULT: All forms will be hidden as RULE3 is not true and thus the form settings becomes the inverse of the true statement.


numberOfOptions = 2


RULE1 is FALSE: hiddenForm1 will be hidden

RULE1 is FALSE: hiddenForm2 will be hidden

RULE1 is FALSE: hiddenForm3 will be hidden


RULE2 is TRUE: hiddenForm1 will be shown

RULE2 is TRUE: hiddenForm2 will be shown

RULE2 is TRUE: hiddenForm3 will be hidden


RULE3 is FALSE: hiddenForm1 will be hidden

RULE3 is FALSE: hiddenForm2 will be hidden

RULE3 is FALSE: hiddenForm3 will be hidden


RESULT: All forms will be hidden as RULE3 is not true and thus the form settings becomes the inverse of the true statement.


numberOfOptions = 3


RULE1 is FALSE: hiddenForm1 will be hidden

RULE1 is FALSE: hiddenForm2 will be hidden

RULE1 is FALSE: hiddenForm3 will be hidden


RULE2 is FALSE: hiddenForm1 will be hidden

RULE2 is FALSE: hiddenForm2 will be hidden

RULE2 is FALSE: hiddenForm3 will be hidden

 

RULE3 is TRUE: hiddenForm1 will be shown

RULE3 is TRUE: hiddenForm2 will be shown

RULE3 is TRUE: hiddenForm3 will be shown

 

RESULT: All forms will be shown as RULE3 is now true.


We're currently reviewing this functionality and looking at other ways of implementing form rule logic. For now, form rules are best used for simpler cases where only one rule of each type is set to affect a field.