# Adding a Dynamic Rule to Workflow Forms

You can add rules to control various aspects of the workflow form user experience. For example, if a user enters incorrect information in a form, you can display a message. You can also show or hide inputs based on the selections or other inputs given by the user.

## Procedure

1. Choose where you want to add a rule:

   - For a workflow, open the properties.

   - For a user interaction activity, open the properties.

2. On the Inputs tab, click Advanced Customization.

   The Advanced Customization dialog box appears.

3. Click Add Rule.

4. For Match below groups when, specify when to apply the rule:

   - To reapply the rule when the user changes the value of any input field in the form, select field changes.

   - To apply the rule when the user opens the form, select form is and Opened.

   - To apply the rule when the user cancels the form, select form is and Cancelled.

   - To apply the rule when the user submits the form, select form is and Submitted.

5. Specify when to apply the rule actions:

   - To apply the rule actions only when all the conditions are met, from the Match list, select all.

   - To apply the rule actions when one or more of the conditions are met, from the Match list, select any.

6. Click Add condition, and then configure one or more conditions based on input values to control when to apply the rule actions.

7. Goal | Steps
   --- | ---
   Set a condition based on the value of the input or if the input value changes. | From the inputs list, select the input. An operator list and a box appear. From the operator list, select the operator to use. For example, to set a condition for when the form contains a certain string, select contains. If the operator requires a value, in the box, enter the value to use.
   Set a condition based on custom JavaScript code. The code must return a Boolean (true or false) value. Tip You can select form inputs using the CSS id selector (#) and the input name. For example, if the input name is UserName, you can use the JQuery selector $('#UserName') to select the input. | From the inputs list, select Custom Script. A script box appears. In the script box, enter the function to use as the condition. Tip To automatically insert inputs as variables in the script, click the ellipse button to the right of the code box and then click the variable that you want to insert.

8. Under Actions, click Add action, and then configure one or more actions to apply to the form if the conditions are met.

9. Goal | Steps
   --- | ---
   Show the input on the form. | From the actions list, select show. From the fields list, select the field name to show.
   Hide the input from the form. | From the actions list, select hide. From the fields list, select the field name to hide.
   Allow the user to submit the form only if they enter data into a form input. | From the actions list, select require. From the fields list, select the field name to make required.
   Allow the user to submit the form with or without entering data into a form input. | From the actions list, select make optional. From the fields list, select the field name to make optional.
   Make the user unable to enter data into a form input. | From the actions list, select disable. From the fields list, select the field name to disable.
   Allow the user to enter data into a form input. | From the actions list, select enable. From the field list, select the field name to enable.
   Automatically populate or change an input value. | From the actions list, select change. From the field list, select the field name to change. In the to box, enter the value that you want to insert.
   Display an informational, error, or warning message to the user that the user can confirm or cancel. | From the actions list, select display a message. In the box to the right, enter the message you want to display to the user. From the top list to the right of the message box, select the type of message you want to display. From the bottom list to the right of the message box, select the confirmation options for the message.
   Make the user unable to submit the form based on certain input values. | From the actions list, select fail validation. In the box to the right, enter the message you want to display to the user.
   Set a condition based on custom JavaScript code. The code must return a Boolean (true or false) value. Tip You can select form inputs using the CSS id selector (#) and the input name. For example, if the input name is UserName, you can use the JQuery selector $('#UserName') to select the input. | From the actions list, select custom script. In the box that appears, enter the function to use as the action. Tip To automatically insert inputs as variables in the script, click the ellipse button to the right of the code box and then click the variable that you want to insert.

10. Verify that the Enabled check box is selected, and then click OK.

    The rule appears at the bottom of the rules order list.

11. To adjust the order of how the rule is applied, click the rule and use the up and down arrows to change the order of the rules.

×

Loading...