Creating a business rule

Here's how you can create a business rule:

  1. First, navigate to the solution and the entity for which the business rule is to be created:
Solution
  1. In the entity components, click on Business Rules to create/modify a business rule:
New Business Rule
  1. Click on the New button to create the business rule:
New Business Rule
  1. To set the scope of the business rule, click on the scope drop-down menu. It will display the following options:
Business Rule Scope

As illustrated in the preceding screenshot, here are some options to set the execution context:

    • If we need to set the execution context of a business rule as the entire entity, we can set it as Entity
    • If we need to set the execution context to all the forms, we can select the All Forms option
    • If we need to set the execution context to a form only, we can just select that particular form
    • To set the condition governing the business rule, click on the condition box:
Adding Condition In Business Rule

 

On the right-hand side, we will get the options to set conditions against the values present in any field. For example, if we want to compare the current Account Category, we can set a condition, as shown in the following screenshot:

Adding Condition In Business Rule

The preceding example shows how a condition is specific to an option set attribute. Similarly, we can also configure a condition specific to attributes with other data types, such as date time, integer, and so on.

We can also configure multiple conditions in the same business rule. The conditions can both be in the same evaluation statement as well as in a different Else If block. The following steps show how both the features can be achieved in the rule:

  1. Adding multiple evaluation criteria in the same rule: If we add multiple rules in the same condition expression, the conditions can be configured with both the and and or operators. Here's how we can add multiple rules in the same condition block:
    1. Firstly, set the value expression in the first rule in the condition expression. Then, click on the + New button:
Adding New Condition In Business Rule

On clicking the + New button, the system should automatically add a new rule for the same condition:

Adding New Condition In Business Rule

Based upon the requirement, we can also configure the two rules by either AND or OR condition.

    1. We can also add multiple condition blocks in the same rule. The idea for doing so is to have multiple Else If conditions in the business rule.
      To do so, you can just click on the + Add button. Doing this will add a new Else If condition in the business rule:
Adding additional condition in business rule

This will add a new condition block in the business rule:

Adding additional condition in business rule
  1. Adding action statements for the condition: Each condition defined inside a business rule must have an action against it. Here's how you can configure the actions in a business rule:
    1. First, select the condition for which you want to configure the action. Then, click the + Add button and select the action that you want to configure:

This is how you can add an additional condition to the business rule:

Adding additional condition in business rule
    1. Now, select the action that needs to be configured. On doing so, the action will be added to the selected condition. You must then select the attribute on which you want the action to be applied to:
Adding additional condition in business rule

Now click on the + sign to add the action:

Adding conditional lock/Unlock action in business rule

Click on the action block to specify the attribute:

Adding lock/unlock action in business rule

Based on the action selected, different fields, such as value selector, will be visible.

    1. After you are done with the addition of all the conditions and corresponding actions, you should click on the VALIDATE button to make sure that the rule has been set correctly. In case there is some issue in the business rule, an error message will appear on the screen:

This is how you can validate the business rule:

Validating business rule