Set up business rules
Business rules control the page UI behavior and business logic. You can specify conditions and actions to take when those conditions are met. This lets you customize page behavior to better suit your needs, streamline data entry, enforce data standards, and improve data quality.
To access business rule configuration on an app page:
-
Click
in the top right → Application Hub.
-
Open the needed app or create a custom app.
-
Open the page or create a custom page.
-
Click the
button in the top right (Fig. 1).
Fig. 1 Open the business rules setup page
View the list of business rules
You can set up business rules on the page or object level. After you set up a page-level rule, Creatio applies it to the elements only on the selected page. After you set up an object-level rule, Creatio applies it to every Freedom UI page that uses the corresponding object, including editable lists. You can set up multiple business rules for a page or object. The list of business rules is displayed on the business rules setup page (Fig. 2).
![Fig. 2 List of business rules](https://academy.creatio.com/docs/sites/en/files/images/NoCodePlatform/business_rules/scr_freedomui_business_rules_list.png)
If multiple rules affect the same page element, only the first rule is activated.
-
Click Add rule to create a new business rule.
-
Select a rule in the list and click its name to view or edit the rule.
-
Select a rule in the list and click the Enabled toggle in the setup area to turn the rule on or off (Fig. 3).
Fig. 3 Turn on the rule -
Select a rule in the list and click
→ Copy to copy the rule.
-
Select a rule in the list and click
→ Delete to delete the rule.
Show/hide an element on a Freedom UI page
You can set up a business rule that shows or hides page elements under specific conditions.
Show the Sick leave, days left field on a request page for requests whose Originator type attribute is an employee.
![Fig. 4 Page rule that shows/hides the element](https://academy.creatio.com/docs/sites/en/files/images/NoCodePlatform/business_rules/scr_freedomui_show_field_rule.png)
To implement this, the Sick leave, days left field must be visible only if the value of the Originator type field is “Employee.” To do this:
-
Open the needed section (e. g., the “Requests” custom app) and add a business rule.
-
Set the filter to define the conditions that trigger the business rule in the “IF” block. For this example apply the rule to requests that have the “Employee” originator type:
- Click Add condition. This adds a condition row.
- Select the “Originator Type” attribute in the new row.
- Leave the “=” (equal) sign as it is.
- Click the
icon and select the “Lookup” field type in the drop-down list. This adds a lookup value field to the right.
- Select the “Employee” lookup value.
-
Set up the action that implements the needed business logic in the “THEN” block. For this example, show the Sick leave, days left field:
- Click Add action → “Show elements.”
- Select the element type to show in the Which element will be shown? block. For this example, select Input. This opens a window.
- Select the field to show on the page, e. g., Sick leave, days left, and click Select.
-
Click Save.
As a result, Creatio will show the Sick leave, days left field only for requests whose Originator type field is set to “Employee.” If the Originator type field is set to any other value, Creatio will hide the Sick leave, days left field.
Make a field required or optional
You can set up a business rule that makes elements required under specific conditions.
Make the Start date and Due date fields on a request page required for requests whose Type attribute is “Vacation.”
![Fig. 5 Page rule that makes the element required](https://academy.creatio.com/docs/sites/en/files/images/NoCodePlatform/business_rules/scr_freedomui_make_field_required_rule.png)
To do this:
-
Open the needed section (e. g., the “Requests” custom app) and add a business rule.
-
Set the filter to define the conditions that trigger the business rule in the “IF” block. For this example apply the rule to requests that have the “Vacation” type:
- Click Add condition. This adds a condition row.
- Select the “Type” attribute in the new row.
- Leave the “=” (equal) sign as it is.
- Click the
icon and select the “Lookup” field type in the drop-down list. This adds a lookup value field to the right.
- Select the “Vacation” lookup value.
-
Set up the action that implements the needed business logic in the “THEN” block. For this example, make the Start date and Due date fields required:
- Click Add action → “Make elements required.”
- Select the element type to make required in the Which element will be required? block. This opens a window.
- Select the fields to make required on the page, e. g., Start date and Due date, and click Select.
-
Click Save.
As a result, Creatio will make the Start date and Due date fields required for requests whose Type field is set to “Vacation.” If the Type field is set to any other value, the fields mentioned will be optional.
Make a field editable or read-only
You can set up a business rule that makes elements editable or read-only under specific conditions.
Make the Owner field on a request page read-only for requests whose Status attribute is “Done” or “Canceled.”
![Fig. 6 Page rule that makes the element read-only](https://academy.creatio.com/docs/sites/en/files/images/NoCodePlatform/business_rules/scr_freedomui_make_field_read_only_rule.png)
To do this:
-
Open the needed section (e. g., the “Requests” custom app) and add a business rule.
-
Set the filter to define the conditions that trigger the business rule in the “IF” block. For this example apply the rule to requests that have the “Done” or “Canceled” status:
- Click Add condition. This adds a condition row.
- Select the “Status” attribute in the new row.
- Leave the “=” (equal) sign as it is.
- Click the
icon and select the “Lookup” field type in the drop-down list. This adds a lookup value field to the right.
- Select the “Done” lookup value.
- Click Add condition. This adds a condition row.
- Select the “Status” attribute in the new row.
- Leave the “=” (equal) sign as it is.
- Click the
icon and select the “Lookup” field type in the drop-down list. This adds a lookup value field to the right.
- Select the “Canceled” lookup value.
-
Set up the action that implements the needed business logic in the “THEN” block. For this example, make the Owner field read-only:
- Click Add action → “Make elements read-only.”
- Select the element type to make required in the Which element will be read-only? block. This opens a window.
- Select the fields to make required on the page, e. g., Owner, and click Select.
-
Click Save.
As a result, Creatio will make the Start date and Due date fields required for requests whose Type field is set to “Vacation.” If the Type field is set to any other value, the fields will be editable.