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

The BINDPARAMETER rule. How to lock a field on an edit page based on a specific condition

Glossary Item Box

Introduction

BINDPARAMETER rule is used for resolving he following tasks:

  • hide and display fields
  • lock and unlock fields
  • make fields required or optional

For more information on business rules, see the “Setting the edit page fields using business rules” article.

In Creatio, you can configure business rules using developer tools the as well as the section wizard. For more information please refer to the “Setting up the business rules”.

Case description

Configure fields on the contact edit page to make the [Business phone] field editable only if the [Mobile phone] field is filled.

Source code

Use this link to download the case implementation package.

Case implementation algorithm

1. Create a replacing client module for the contact page

Create a replacing client module and specify the [Display schema — Contact card] schema as parent object (Fig. 1). The procedure for creating a replacing page is covered in the “Creating a custom client module schema” article.

Fig. 1. Order edit page replacing schema properties

2. In the rules property of the page view model, add the rule

For the Phone column, add the rule with the BINDPARAMETER type to rules property of the page view model. Set the BusinessRuleModule.enums.Property.ENABLED. Value for the rule’s property. Add the following condition for rule execution to the conditions array: the value in the MobilePhone column should be filled.

The replacing schema source code is as follows:

// Add the module BusinessRuleModule to the list of dependent modules.
define("ContactPageV2", ["BusinessRuleModule"], function(BusinessRuleModule) {
    return {
        // Name of the page schema of the edit page.
        entitySchemaName: "Contact",
        // Rules of the edit page view model.
        rules: {
            // A set of rules for the [Business phone] column of the view model.
            "Phone": {
                // Dependence of the availability of the [Business phone] field from the value of the [Mobile phone] field.
                "BindParameterEnabledPhoneByMobile": {
                    // The type of the BINDPARAMETER rule.
                    "ruleType": BusinessRuleModule.enums.RuleType.BINDPARAMETER,
                    // The rule regulates the ENABLED property. 
                    "property": BusinessRuleModule.enums.Property.ENABLED,
                    // An array of conditions in which the rule is triggered. 
                    // Determines whether the [Mobile Phone] field is populated. 
                    "conditions": [{
                        // Expression of the left side of the condition.
                        "leftExpression": {
                            // The type of the expression is the attribute (column) of the view model. 
                            "type": BusinessRuleModule.enums.ValueType.ATTRIBUTE,
                            // The name of the column in the view model, whose value is compared in the expression.
                            "attribute": "MobilePhone"
                        },
                        // The type of comparison operation is "not equal to". 
                        "comparisonType": Terrasoft.ComparisonType.NOT_EQUAL,
                        // Expression of the right side of the condition.
                        "rightExpression": {
                            // The expression type is a constant value.
                            "type": BusinessRuleModule.enums.ValueType.CONSTANT,
                            // The value with which the left side expression is compared.
                            "value": ""
                        }
                    }]
                }
            }
        }
    };
});

After saving the schema and refreshing the application page, the [Business phone] field will be non-editable until the [Mobile phone] field is empty (Fig. 2).

Fig. 2. Example result demonstration

See also

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?