Set up the conditions that lock a field on a record page
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
-
Go to the Configuration section and select a custom package to add the schema.
-
Click Add → Replacing view model on the section list toolbar.
-
Fill out the schema properties.
- Set Code to "ContactPageV2."
- Set Title to "Display schema - Contact card."
- Select "ContactPageV2" in the Parent object property.
-
Add the
BusinessRuleModule
module as a dependency to the declaration of the view model class. -
Set up the conditions that lock the field.
-
Take the following steps in the
rules
property for the Phone column:- Set the
ruleType
property toBINDPARAMETER
. The value sets the business rule type. TheBusinessRuleModule.enums.RuleType
enumeration represents the rule types. - Set the
property
property toENABLED
. The value sets the column availability. TheBusinessRuleModule.enums.Property
enumeration represents the properties of theBINDPARAMETER
business rule. - Specify the execution conditions of the business rule in the
conditions
array. The MobilePhone column value cannot be empty.
- Set the
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": ""
}
}]
}
}
}
};
}); -
-
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.