Create a Rule for Forms

Use a form rule to override properties for fields in a dynamic form, assuming that certain conditions are met at runtime.

To create a form rule:

  1. Open the Business Rules tab in the Layout.

    If you are in the Page Designer, you can select the dynamic form on the page, and then click Go to Rule Set in the Properties pane to open the Rule Sets tab, then open the Business Rules tab.

  2. In the business rules editor, click Create Rule next to Form Rules to open the Create Business Rule dialog box.


    Rather than creating a rule from scratch, you can duplicate an existing rule and use it as the basis for a new rule, or create a rule from a business rule template. To duplicate a rule, right-click the rule in the list, and then click Duplicate.

    Note:

    When duplicating rules defined in extension dependencies (the rules listed under Built-in Rules):
    • You cannot duplicate a rule if it uses advanced expressions, for example, in the rule's condition or to override a field's value.
    • You cannot duplicate a rule if it uses any global functions that cannot be referenced in the extension. If the global functions are referenceable, when the rule is duplicated they are automatically imported, and the references to the function are updated in the rule.
    • When duplicating nested rules, you can only duplicate the top-level rule. When you duplicate the rule, the child rules are also duplicated.

    If there are any business rule templates defined in the Layout, you can select one using the Template dropdown list in the Create Business Rule dialog box:



  3. Select the Rule Type in the dialog box.
    Select Regular to create a standard business rule. The other rule types (If/else and Switch) are special types of nested rules. For more about these nested rules, see Add an If/Else Rule and Add a Switch Rule.
  4. Enter a label, id, and description for the rule.
    The id is generated automatically based on the label you enter, but you can modify the id if you wish. The description field is not required, but it can be helpful when you later try to understand what a rule is doing, especially when there are many rules.
  5. Click Create

    Your new rule is added to the top of the list of built-in rules under Form Rules.

  6. Create the rule's condition.
  7. Specify the overrides for the field properties.

To delete a rule, right-click the rule in the list to open the popup menu, and then click Delete.

Rules are evaluated in order, from bottom to top. As you create more rules, make sure you position each one in the order you want them evaluated, using the grab handles (six dots) beside the rules to drag-and-drop them to new positions. You can find out more about how rules are evaluated in Understand What Will Be Shown at Runtime.

If you decide you don’t want to include a rule in the evaluation order, select the rule, then use the Active toggle switch in the upper right corner to deactivate it. (You can also right-click a rule and deactivate and activate it in the popup menu.) This enables you to still keep the rule so you can re-activate it later. You can tell at a glance if a rule is inactive because a little badge appears next to it, like this:



Inactive rules are not included in the rule evaluation process.

Note:

You can deactivate all the rules at once by clicking the three dots next to the Built-in Rules heading, then clicking Deactivate All. This can be useful when debugging a page, allowing you to see the page with no rules applied. Use Activate All to reinstate all the rules at once, or use the Active toggle to selectively activate them as you work through your debugging process.