Create Templates for Business Rules
You can create business rule and validation templates to help users when they create new business rules. By providing templates, a user can create a rule from a template and modify it as needed, instead of starting with an empty rule.
A template can provide examples of how to configure business and validation rules, for example, how to specify rule conditions, how to write advanced expressions, or examples of how to override properties. Templates themselves are not evaluated.
Templates are defined in the Layout. If you create a new Layout in your extension, you can define business rule templates in the Layout (in metada-rules.json
) using the business rules editor. You cannot define business rule templates if you're extending a Layout in a dependency.
Let's say you add a new service connection, and then add a dynamic form that is bound to a business object in that service. A new Layout is created representing the business object. If you plan to use business rules with the component, you can define a business rule template that defines a condition and some property overrides, for example, hiding some fields when the user is in the UK. Anyone extending the Layout can then choose to use the template when creating their own business rules. After creating a rule from the template, they could then edit the rule, for example, so that the fields are hidden for users in Canada instead of the UK.
When a user creates a business rule, if the Layout defines a business rule or validation template, the dialog box for creating the rule contains a Template dropdown list. The user can choose to create an empty rule, or a rule based on the template, and then modify the rule as needed.