Create an Extension Rule in a Rule Set

Once you've opened a rule set, you can create a rule by defining the rule's conditions, and which fields are displayed in its layout when the rule's conditions are met.

The rule set editor lists rules defined in the extension dependency under Built-In Rules. You cannot edit the rules under Built-in Rules, but you can copy them to use as the basis for your own rules. The rules that you create and can edit are listed under Extension Rules.

Like business rules, the order in which rules appear in the Extension Rules list is important. However, unlike business rule, rules in rule sets are evaluated at runtime from top to bottom. The first rule where all the conditions are met determines the layout used. None of the rules below it in the list are tested. Keep this in mind as you’re working on the rules.

  1. Open the page you want to modify in the Designer.
  2. Locate the component layout you want to edit on the page or in the Properties pane, and then click Edit Layout to open the editor.

    Let's look at the rule set for a form layout as it appears in the editor:



    The left pane of the editor lists the rule set's rules. This rule set has one built-in rule (isDefault). To the right, the selected rule's conditions are displayed above the list of fields in the rule's layout.

  3. Click Add Rule button in the left pane to create a new extension rule, and then provide a name and description in the popup dialog.

    You can delete or duplicate a rule by right-clicking the rule, and then selecting Delete or Duplicate in the popup options menu.

  4. Change the order of the extension rules in the list by grabbing a rule and dragging it into the position you want.
    Rules are evaluated from the top down, so make sure the rules are in the order you want them evaluated.
  5. Click Edit in your rule to open the condition builder, and then define its conditions.

    The condition builder is the same one used to create conditions for extension rules in business rules. You can click Code to write the condition in the code editor. If you're not familiar with using the condition builder, see Set Conditions for an Extension Rule.



    Click Done to close the condition builder. Your changes are automatically saved.

  6. Select the fields you want displayed in the layout.

    Add a field or object to a layout by selecting the checkbox next to the field, or by dragging it from the list into the layout:



    The layout editor contains a Fields palette listing all the fields that can be displayed in the layout. This palette is displayed by default when you create a new rule. You can click Hide Fields in the toolbar to hide the Fields palette. If the palette is hidden, click Show Fields.

    The fields you can display in a rule's layout are determined by the fields available from the data resource used by the component. This data resource is defined in the extension dependency. You can choose any of the fields listed in the Fields palette—and the order in which they should appear—but you can't include fields from other data resources.

    To help you locate the fields you might want to add, the Fields palette might contain a Suggested Fields section at the top of the palette. This section lists the fields that have been identified as the most relevant or most important when building your layout.

    You can also filter the list of fields by entering a string in the Filter field at the top of the Fields palette.

  7. (Optional) Group fields by selecting all the fields that you want to include in the group, either by holding down the CMD key (on macOS) or the Ctrl key (on Windows), and then clicking Group Fields in the toolbar.

    The selected fields are grouped under a folder in the list. You can type a name for the new folder in the layout editor:



    You use groups to divide a dynamic form into different sections. Each subsection has a heading based on the group name.

    To ungroup the fields in a group, select the group and then click Ungroup in the toolbar.

  8. Organize the order that fields and groups are displayed in the component by dragging its handle and dragging it into position in the layout.

    Note:

    When the rule's conditions are met, you can see the changes you make to the page in the Designer. (You need a browser window wide enough so that the page is visible on the left, next to the editor.)
  9. Click X at the top of editor to close it.