How to block the edit page field by a specific condition
Glossary Item Box
Case description
Set fields on the contact edit page so that the [Account] field is accessible only when the [Name] field is filled.
Case implementation algorithm
1. Create a replacement client module of the contact edit page
A replacement client module must be created and [Display schema – Contact card] (Fig. 1) must be specified as the parent object.
The process of creating the replacement page is described in the article Creating a custom client module schema
Fig. 1. — Properties of the replacement edit page
2. Add a rule with the BINDPARAMETER type for the [Account] column to the rules property of the page view model
3. Initialize the property property of the rule for the [Account] column using the BusinessRuleModule.enums.Property.ENABLED value
4. Add a condition for the rule implementation to the conditions array – the [Name] column value of the model cannot be undefined
// Add BusinessRuleModule to the list of module dependencies. define("ContactPageV2", ["BusinessRuleModule", "ConfigurationConstants"], function (BusinessRuleModule, ConfigurationConstants) { return { // Object schema name of the edit page. entitySchemaName: "Contact", details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/, diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/, // Rule object for the edit page view model. rules: { // Rule set for the [Account] column of the view model. "Account": { // Rule that determines dependency of the [Account] field availability // from the value in the [Name] field. BindParameterEnabledAccountByName: { // BINDPARAMETER rule type. ruleType: BusinessRuleModule.enums.RuleType.BINDPARAMETER, // The rule regulates the ENABLED property of the field. property: BusinessRuleModule.enums.Property.ENABLED, // Array of conditions required for the rule to trigger. // In this case the array contains single condition that // determines whether the [Name] column has value. conditions: [{ // Expression of the left part of the condition. leftExpression: { // The ATTRIBUTE expression type points to the fact that // a view model attribute (column) is used as expression. type: BusinessRuleModule.enums.ValueType.ATTRIBUTE, // Name of the view model column, whose value is compared in // the expression. attribute: "Name" }, // Type of the comparison operation. comparisonType: Terrasoft.ComparisonType.NOT_EQUAL, // Expression of the right part of the condition. rightExpression: { // The CONSTANT expression type points to the fact that // a constant expression is used. type: BusinessRuleModule.enums.ValueType.CONSTANT, // The value whith which the expression in the left part. value: undefined } }] } } } }; });
5. Save the created replacement page schema
When the schema is saved and the web-page of the system is updated on the contact edit page, the [Account] field will be uneditable until data are set into the [Full Name] field (Fig. 2, 3).
Fig. 2. — Demonstrating the case implementation result (the [Full Name] is not filled; the [Account] field is blocked).
Fig. 3. — Demonstrating the case implementation result (the [Full Name] is filled; the [Account] field is available).