Creatio development guide
PDF
This documentation is valid for Creatio version 7.15.0. We recommend using the newest version of Creatio documentation.

Setting the edit page fields using business rules

Glossary Item Box

Introduction

Business rules are one of the tools to setup page logic in Creatio.

Business rules are a standard Creatio mechanism that enables you to set up the page field behavior by configuring the view model columns.

Business rules enable you to:

  • hide and display fields
  • lock and unlock fields
  • make fields required or optional
  • filter the lookup field value depending on another field value

You can add business rules in two ways:

1. Via section wizard or detail wizard.

  • Wizard generated business rules are added to the businessRules client module property.
  • The generated business rules have higher priority at execution.
  • BusinessRuleModule enumerations are not used when describing the generated business rules.

See the "Setting up business rules” article for more information on business rule setup via wizard. The manual setup of the generated business rules is covered in the "Business rules. The businessRules property” article.

2. Via configuring the “rules” property of the client module schema.

The functions of business rules are implemented in the BusinessRuleModule client module. To use these functions, add the BusinessRuleModule module to the list of user schema dependencies of the view model.

Case of declaring user module with using business rules

define("CustomPageModule", ["BusinessRuleModule"], function(BusinessRuleModule) {
    return {
        // View model schema implementation.
    };
});

NOTE

Capability of adding business rules by developer tools ensures compatibility with previous versions.

General requirements to business rule declaring in a client module

  • All rules are described in the rules property of the page view model.
  • The rules are applied to view model columns and not to control elements.
  • Business rules are not supported on list pages.
  • Rules have names.
  • Rule parameters are set in its configuration object.

Examples of business rule declaring

// List of view model rules.
rules : {
    // Name of the column where the rule is added.
    "FirstColumnName" : {
        // FirstColumnName column list of rules.
        // Rule name.
        FirstRuleName : {
            // FirstRuleName configuration object.
            ruleType: <BusinessRuleModule.enums.RuleType enumeration value>
            // The rest of rule configuration properties.
        },
        SecondRuleName: {
            // SecondRuleName configuration object.
            ruleType: <BusinessRuleModule.enums.RuleType enumeration value>
            // The rest of rule configuration properties.
        }
    },
    "SecondColumnName" : {
        // SecondColumnName column list of rules.
        ...
    }
}

Business rule types

Rule types are defined in the RuleType enumeration of the BusinessRuleModule module.

Currently two rule types are used – BINDPARAMETER and FILTRATION.

BINDPARAMETER

This rule type is used for linking properties of a column to values of different parameters. For instance, for setting up the visibility of a column or to enable a column depending on the value of another column. The main BINDPARAMETER configuration object properties are described in table 1.

Table 1. – BINDPARAMETER configuring

Property Value
ruleType

Type of the rule. It is defined by the BusinessRuleModule.enums.RuleType enumeration value.

In this case BINDPARAMETER type is used.

property

Control element property. Set by the BusinessRuleModule.enums.Property enumeration value:

  • VISIBLE – column visibility
  • ENABLED – enabling of a column
  • REQUIRED – column populating is required
  • READONLY – column for reading only
conditions

Condition array for rule application.

Every condition represents a configuration object, whose properties are described in table 2.

logical

Logical operation of combining the conditions from the conditions property. Set by the Terrasoft.LogicalOperatorType enumeration value.

Table 2. – BINDPARAMETER configuring

Property Value
leftExpression

Expression of the left side of the condition. Represents a configuration object with the following properties:

  • Type – expression type. Set by the BusinessRuleModule.enums.ValueType enumeration value:
    • CONSTANT – constant value
    • ATTRIBUTE – the view model column value
    • SYSSETTING – system setting
    • SYSVALUE – system value The Terrasoft.core.enums.SystemValueType system value list element.
  • Attribute – model column name
  • attributePath – meta-path to the lookup schema column
  • Value – value for comparison
comparisonType

Type of comparison. Set by the Terrasoft.core.enums.ComparisonType enumeration value.

rightExpression Expression of the right side of the condition. Similar to leftExpression.

FILTRATION

Use the FILTRATION rule to set up filtering of values in view model columns. For example, you can filter a lookup column depending on the current status of a page.

Table 3. – FILTRATION configuring

Property Value
ruleType

Rule type. Set by the BusinessRuleModule.enums.RuleType.enumeration value.

In this case FILTRATION type is used.

autocomplete Reverse filtering checkbox. Can take the true or false values.
autoClean The checkbox of automated value cleaning upon changing the column that is used for filtration. Can take the true or false values.
baseAttributePatch

Meta-path to the lookup schema column that will be used for filtration.

The feedback principle is applied when building the column path similar to EntitySchemaQuery,. The path is generated in relation to the schema, referred to by the model column.

comparisonType

Type of comparison operation. Set by the Terrasoft.ComparisonType.enumeration value.

type

The value type for comparison baseAttributePatch. Set by the BusinessRuleModule.enums.ValueType enumeration value.

attribute

The view model column name. This property is described if ATTRIBUTE value type (type) is indicated.

attributePath

Meta-path to the object schema column.

The feedback principle is applied when building the column path similar to EntitySchemaQuery,. The path is generated in relation to the schema, referred to by the model column.

value

Filtration value. This property is described if ATTRIBUTE value type (type) is indicated.

See also

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?