Introduction

Business Rules in Visual Builder Express mode allow you to define the conditions that must be satisfied in order to control theVB page in some manner, for instance, to control the regions and fields that are visible, or to define a validation rule.

Launch Business Rule editor

When you enter the editor within Visual Builder Express mode, if the page supports business rules to control the display of fields and regions the “Configure Fields and Regions” button will be visible and this will take you into the Business Rule editor.

Similarly, if the page supports Defaulting and Validation the “Validate Field Values” button will be visible and this will take you into the Business Rule editor.

Business Rules ButtonValidation Rules

Existing Business Rules

The page is likely to have set of pre-configured rules that determine its default behaviour. These are listed in the Built-in Rules section.

Built In Rules

 Work with existing rules

You can search for existing rules based on various criteria, for example if the rule impacts the Assignment Cateogry field:

Filter Rule

You can move Extension Rules (those that are not Built-in Rules) up and down to control the order in which they are evaluated, you can also activate/deactive and delete existing rules by right clicking on the rule name to access the following dropdown list:

Move and Duplicate Rules

Business Rules are evaluated from the bottom of the list upwards. So a rule that is higher in the list will take precedence over one that is lower down.

For instance if there are two rules with the same condition, the lower of which hides the Job field and higher makes it visible, the effect will be that the higher rule takes is evaluated later and the Job field will be made visible.

Define a new rule

You can add new rules that overlay the pre-configured rules, to personalize the page.

Add a new rule by pressing the “+ Rule” on the top left pane. Enter the name and description of the business rule press the Create button.

Create Business Rule

A new rule will be created showing an initial set of default conditions. The intial set of conditions show the contexts that are passed into the page when it is 1st rendered.

Default Conditions

You can toggle between different modes to see the definition of your business rule.

In View mode you see a summary of the rule

In Design mode you can modify the existing condition and add new conditions

In Advanced mode you can see the code that is generated when you create the condition and you can amend it if required.

Toggle between View and Design modes

Advanced Condition

Layout of a business rule

A business rule is made up of a set of conditions that can either be applied using an AND or an OR construct. An AND construct is applied if the set of conditions are grouped together with the ALL must apply setting. An OR construct is applied if the set of conditions are grouped together with the ANY must apply setting.

The following shows a condition where both the Country and Department criteria must be true:

All Conditions must be true

Grouping rules together

It is possible to have groups of conditions that themselves can be evaluated on an AND or OR basis.

This allows you to build up conditions such as

IF (Country=US and Department=Sales) OR (Country=CA and Department=Marketing) then true.

Grouped Conditions

Nesting rules

You can also nest rules within other rules so that you can build conditions such as
IF (Country=US) then
  IF (Department=Sales) then true
ELSE IF (Country=CA) then
  IF (Department=Marketing) then true

To define a nested rule within a rule, click on the “+” button to the right of the rule name.

Indented Rules

Defining a condition

Each line in rule is a condition of the form:

{Criterion} {Operator} {Value}

For instance
Country = US

The types of criterion that can be used include Page Contexts, Fields and User Properties

A page context is a value that is set up when the page is initialized and which remains constant throughout the lifetime of the page.

Fields are attributes that are present in the UI. In some cases you can choose to use the “Initial Value” of the attribute – i.e. the value when the page was initiated. Otherwise you should use the “Value”.

Field Attributes

User Properties are those attributes associated with the logged in user, including the following

User Properties

The options available in the operator dropdown menu are pre-defined based upon the criterion’s type. So for a criterion like User Authenticated, the operator menu has just equals, and the only available values in the menu are Yes and No.

Operator Limited

View the generated code

If you want to view or edit the condition as an expression, you can click Code from within the Advanced Expresssion editor to switch to a code editor where you can see the javascript that is generated.

Code editor

Summary

This summary of how to define business rules is part of a Learning Path available in the HCM COE Blog pages.
Please go there to access other useful blogs to help you withe your Visual Builder journey.