Is this really the version you are looking for? Kentico Xperience 8.1 Documentation is no longer updated. Use the switcher in the header to choose your product version.
Macro rules allow you to create macro conditions without any knowledge of the Kentico macro language (K#). Instead of writing code, you build conditions out of text-based clauses. Each macro rule represents a requirement, which can either be true or false at the time when the system evaluates the condition.
To create a condition using macro rules, click Edit next to a condition field in the user interface. The Rule designer dialog opens.
Select the rule in the list of Available rules.
Tip: Use the filter above the list to find the rules that you need.
Click Add rule ().
The rule appears in the main designer area, displayed as a text description of the corresponding requirements.
Parameters allow you to configure the exact requirements of macro rules. For example, in a rule that requires the current user to be a member of certain roles, you select the roles through a parameter.
Macro rules display parameters as underlined sections within the rule text. To set the value of a parameter, click the underlined text and fill in the value inside a separate dialog.
If you add multiple rules to a condition, the rule designer automatically places operators between the rules.
Click on operators to switch between the two options. The final result of the condition depends on the results of individual rules, and the operators placed between them.
The rule designer uses indentation to group together macro rules and set the precedence of the operators. The system first evaluates the rules on the level with the largest indentation. The result is passed to the level above, and this process continues until the final result of the condition is known.
To increase or decrease the indentation, select a rule and click Indent or Unindent on the toolbar above the designer area. Clicking Auto indent modifies the indentation of all rules in the condition — ensures precedence for all groups of rules connected through the and operator.
You can change the order of the rules by dragging them to different positions in the designer area.
You can delete rules by clicking buttons on the toolbar above the designer area:
You can view the K# code of the overall condition defined by the added macro rules. Click View condition in K# () on the toolbar.
If you wish to manually edit the code, switch to the dialog's Code tab.
Note: The system cannot convert general macro code into macro rules. If you edit a condition on the Code tab, the content of the rule designer is deleted.