Use Nested Rules
Nested rules help you avoid having to write complicated conditions and can improve rule organization, especially if you have lots of rules.
A nested rule is simply a parent rule with one or more child rules, indicated in the UI by indentation. When you use nested rules, the children of a rule can override the properties set by its parent(s).
In addition to the typical nested rules, there are two special types of nested rules (If/Else and Switch) that behave slightly differently. These special types are described later, but first let's look at typical nested rules.
Here's a simple example of a nested rule:
This example shows two sets of nested rules:
- Country is USA and Country is Canada are at the same level
 - Full Time Employees is nested beneath Country is USA
 - Hire Date before 2023 and Hire Date after 2023 are both children of Full-time Employees.
 
The red numbers indicate the order in which these rules are evaluated at runtime. Let’s take a closer look at what that means:
- Evaluation begins at the bottom with Country is Canada. If the conditions for this rule are met, the rule’s property overrides are applied. Next:
 - Country is USA is evaluated. 
                     
- If the rule's conditions are NOT met, the rule doesn't override any properties. In addition, its child rules (Full-time Employees) are never evaluated.
 - If the conditions for Country is USA ARE met, the property overrides defined in the rule are applied, and Full-time Employees is evaluated.
 
 - If the conditions for Full-time Employees are NOT met, the rule does not apply any properties, and its children (Hire Date after 2023 and Hire Date before 2023) are never evaluated.
 - If the conditions for Full-time Employees ARE met, the property overrides defined in the rule are applied, and its children are evaluated.
                     
- Hire Date after 2023 is evaluated first, because it is lowest, followed by Hire Date before 2023.
 
 
Although you could write a more complex set of conditions to achieve the same outcome, nested rules make it much simpler to apply multiple property overrides at runtime.
Add a child rule
You can add a child rule to any of your extension rules:
- Click 
 next to the rule that you want to be the parent rule. - Type the Label of the child rule. (The ID field is automatically populated based on the Label, but you can type a different ID if you want.) Click Create.
 - Right-click the child rule, and then use Move up and Move down in the options menu to move the rule into the position you want.
                        
Remember, child rules that are peers are evaluated from the bottom up, so the order is important.
 
When you duplicate a rule, the rule's children are also duplicated. In the example above, if you duplicated Full-time Employees, a new rule (Full-time Employees copy) will appear under the parent (Country is USA), along with its child rules Hire Date not set, Hire Date before 2023, and Hire Date after 2023.
Add an If/Else Rule
An If/Else rule is a special type of nested rule where only the first child rule meeting the conditions is applied, and none of the remaining child rules are evaluated.
You use an If/Else nested rule when only one of the rules in a list of rules needs to be applied. Unlike regular business rules, where every rule is evaluated, the child rules in an If/Else rule are evaluated in order until one is applied; the unevaluated child rules are skipped. This means that rules won't be evaluated if they don't need to be.
For example, you might have a rule that should be applied when the user's role is Sales Manager, and some rules that should only be applied when the user is a sales manager in the UK, or in Canada. Handling this type of situation, where only one rule should be applied, is very simple if you use nested If/Else rules. Let's take a look at how you could do this.
Add a Switch Rule
A Switch rule is a special type of nested rule where instead of evaluating a list of rules, a switch parameter (switchOn) is evaluated, and the parameter's value determines which case is applied.
Let's say you want to apply a rule based on the role of the current user, and there are several different cases. For example, when the user's role is Sales Manager, you want the Sales Manager rule applied, when it's Administrator, the Administrator rule is applied, and so on. You can use the Switch nested rule to apply the appropriate rule based on the value of the user roles field, instead of evaluating a long list of rules at runtime.
Let's create a Switch rule that evaluates the role of a logged in user. You then create some different cases, for example, one case if the user role is Sales Manager, and another case if the role is Administrator. At runtime, the user role is evaluated, and based on the user role value, the appropriate case is applied.









