Skip to main content
Version: 8.1

Set up the conditions that lock a field on a record page

Level: intermediate
Example

Set up the conditions that lock the Business phone field on the contact page. Lock the field if the Mobile phone field is empty.

Create a replacing view model schema of the contact page

  1. Go to the Configuration section and select a custom package to add the schema.

  2. Click AddReplacing view model on the section list toolbar.

  3. Fill out the schema properties.

    • Set Code to "ContactPageV2."
    • Set Title to "Display schema - Contact card."
    • Select "ContactPageV2" in the Parent object property.
  4. Add the BusinessRuleModule module as a dependency to the declaration of the view model class.

  5. Set up the conditions that lock the field.

    1. Take the following steps in the rules property for the Phone column:

      • Set the ruleType property to BINDPARAMETER. The value sets the business rule type. The BusinessRuleModule.enums.RuleType enumeration represents the rule types.
      • Set the property property to ENABLED. The value sets the column availability. The BusinessRuleModule.enums.Property enumeration represents the properties of the BINDPARAMETER business rule.
      • Specify the execution conditions of the business rule in the conditions array. The MobilePhone column value cannot be empty.

    View the source code of the replacement view model of the contact page below.

    ContactPageV2
    /* Specify the BusinessRuleModule module as a dependency. */
    define("ContactPageV2", ["BusinessRuleModule"], function(BusinessRuleModule) {
    return {
    /* The name of the record page object's schema. */
    entitySchemaName: "Contact",
    /* The business rules of the record page's view model. */
    rules: {
    /* The set of rules for the [Phone] column of the view model. */
    "Phone": {
    /* The requirement of the [Phone] field depends on the [MobilePhone] field value. */
    "BindParameterEnabledPhoneByMobile": {
    /* The BINDPARAMETER rule type. */
    "ruleType": BusinessRuleModule.enums.RuleType.BINDPARAMETER,
    /* The rule controls the ENABLED property. */
    "property": BusinessRuleModule.enums.Property.ENABLED,
    /* The array of conditions that trigger the rule. Check whether the [MobilePhone] column contains a value. */
    "conditions": [{
    /* The left side expression of the condition. */
    "leftExpression": {
    /* The expression type is attribute (column) of the view model. */
    "type": BusinessRuleModule.enums.ValueType.ATTRIBUTE,
    /* The name of the view model column whose value to compare in the expression. */
    "attribute": "MobilePhone"
    },
    /* Set the comparison operation type to not equal. */
    "comparisonType": Terrasoft.ComparisonType.NOT_EQUAL,
    /* The right side expression of the condition. */
    "rightExpression": {
    /* Set the expression type to a constant value. */
    "type": BusinessRuleModule.enums.ValueType.CONSTANT,
    /* The value to compare to the left side expression. */
    "value": ""
    }
    }]
    }
    }
    }
    };
    });
  6. Click Save on the Designer's toolbar.

Outcome of the example

To view the outcome of the example, refresh the Contacts section page.

As a result, Creatio will lock the Business phone field on the contact page if the Mobile phone field is empty.


Resources

Package with example implementation