rules and businessRules properties

Beginner

The rules and businessRules properties of the client schema contain a configuration object with its own properties.

Primary properties 

ruleType

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

Available values (BusinessRuleModule.enums.RuleType)
BINDPARAMETER Business rule type. Use this rule type to link properties of a column to values of different parameters. For example, set up the visibility of a column or enable a column depending on the value of another column.
FILTRATION Business rule type. Use the FILTRATION rule to set up filtering of values in view model columns. For example, filter a LOOKUP column depending on the current status of a page.
property

Use for the BINDPARAMETER business rule type. Control property. Set by the BusinessRuleModule.enums.Property enumeration value.

Available values (BusinessRuleModule.enums.Property)
VISIBLE Whether visible.
ENABLED Whether available.
REQUIRED Whether required.
READONLY Whether read-only.
conditions

Use for the BINDPARAMETER business rule type. Condition array for rule application. Each condition is a configuration object.

Properties of the configuration object
leftExpression Expression of the left side of the condition. Represented by a configuration object.
Properties of the configuration object
type

The expression type. Set by the BusinessRuleModule.enums.ValueType enumeration value.

Available values (BusinessRuleModule.enums.ValueType)
CONSTANT A constant.
ATTRIBUTE The value of the view model column.
SYSSETTING System setting.
SYSVALUE A system value. The list element of the Terrasoft.core.enums.SystemValueType system values.
attribute

Name of the model column.

attributePath

Meta-path to the lookup schema column

value

Comparison value.

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.
logical

Use for the BINDPARAMETER business rule type. The logical operation that combines the conditions from the conditions property. Set by the Terrasoft.LogicalOperatorType enumeration value.

autocomplete

Use for the FILTRATION business rule type. Reverse filtering flag. Can be true or false.

autoClean

Use for the FILTRATION business rule type. The flag that enables automated value cleanup when the column by which to filter changes. Can be true or false.

baseAttributePatch

Use for the FILTRATION business rule type. Meta-path to the lookup schema column that will be used for filtering. Apply the feedback principle when building the column path, similar to EntitySchemaQuery. Generate the path relative to the schema to which the model column links.

comparisonType

Use for the FILTRATION business rule type. Type of comparison operation. Set by the Terrasoft.ComparisonTypeenumeration value.

type

Use for the FILTRATION business rule type. The value type for comparison baseAttributePatch. Set by the BusinessRuleModule.enums.ValueType enumeration value.

attribute

Use for the FILTRATION business rule type. The name of the view model column. Describe this property if the ATTRIBUTE value type is indicated.

attributePath

Use for the FILTRATION business rule type. Meta-path to the object schema column. Apply the feedback principle when building the column path, similar to EntitySchemaQuery. Generate the path relative to the schema to which the model column link.

value

Use for the FILTRATION business rule type. Filtration value. Describe this property if the ATTRIBUTE value type is indicated.

Additional properties 

Use additional properties only for the businessRules property.

uId.

Unique rule ID. The "GUID" type value.

enabled

Enabling flag. Can be true or false.

removed

The flag that indicates whether the rule is removed. Can be true or false.

invalid

The flag that indicates whether the rule is valid. Can be true or false.

Use examples
define("SomePage", [], function() {
    return {
        /* ... */
        businessRules: /**SCHEMA_BUSINESS_RULES*/{
        /* A set of rules for the Type column of the view model. */
        "Type": {
            /* The rule code the Wizard generates. */
            "ca246daa-6634-4416-ae8b-2c24ea61d1f0": {
                /* Unique rule ID. */
                "uId": "ca246daa-6634-4416-ae8b-2c24ea61d1f0",
                /* Enabling flag. */
                "enabled": true,
                /* The flag that indicates whether the rule is removed. */
                "removed": false,
                /* The checkbox that indicates whether the rule is valid. */
                "invalid": false,
                /* Rule type. */
                "ruleType": 0,
                /* The code for the property that controls the rule. */
                "property": 0,
                /* A logical relationship between several rule conditions. */
                "logical": 0,
                /* An array of conditions that trigger the rule.
               Compare the Account.PrimaryContact.Type value to the Type column value. */
                "conditions": [
                    {
                    /* Type of comparison operation. */
                    "comparisonType": 3,
                    /* Expression of the left side of the condition. */
                    "leftExpression": {
                        /* The expression type is a column (attribute) of a view model. */
                        "type": 1,
                        /* The name of the view model column. */
                        "attribute": "Account",
                        /* Path to the column in the Account lookup schema, whose value to compare in the expression. */
                        "attributePath": "PrimaryContact.Type"
                    },
                    /* Expression of the right side of the condition. */
                    "rightExpression": {
                        /* The expression type is a column (attribute) of a view model. */
                        "type": 1,
                        /* The name of the view model column. */
                        "attribute": "Type"
                    }
                    }
                ]
            }
        }
        }/**SCHEMA_BUSINESS_RULES*/
        /* ... */
    };
});
define("SomePage", [], function() {
    return {
        /* ... */
        businessRules: /**SCHEMA_BUSINESS_RULES*/{
        /* A set of rules for the Type column of the view model. */
        "Account": {
            /* The rule code the Wizard generates. */
            "a78b898c-c999-437f-9102-34c85779340d": {
                /* Unique rule ID. */
                "uId": "a78b898c-c999-437f-9102-34c85779340d",
                /* Enabling flag. */
                "enabled": true,
                /* The flag that indicates whether the rule is removed. */
                "removed": false,
                /* The flag that indicates whether the rule is valid. */
                "invalid": false,
                /* Rule type. */
                "ruleType": 1,
                /* Path to the column for filtering in the Account lookup schema referenced in the Type column of the edit page view model. */
                "baseAttributePatch": "PrimaryContact.Type",
                /* The comparison type in the filter. */
                "comparisonType": 3,
                /* Expression type is a column (attribute) of a view model. */
                "type": 1,
                /* Name of the view model column, by which to filter the records. */
                "attribute": "Type"
            }
        }
        }/**SCHEMA_BUSINESS_RULES*/
        /* ... */
    };
});