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

How to hide the edit page field by a specific condition

Glossary Item Box

Case description

Add a new [Meeting Place] field to the activity edit page. The field will be displayed only for [Visit] type activities.

NOTE

A field to the edit page may be added by two ways – using the Section Wizard and manually.

The process of adding a field to the edit page is described in the article Adding a new field to the edit page.

Case implementation algorithm

1. Create a [Activity] replacement object and add a new [Meeting Place] column

For this purpose, select a user package and run the [Add] > [Replacing Object] menu item (Fig. 1) on the [Schemas] tab.

Fig. 1. – Creating the replacement schema of the object

Fill the new object properties by specifying [Activity] as the parent object (Fig. 2).

Fig. 2. — Properties of the [Activity] replacement object

Add the new text column [Meeting Place] to the replacement object (Fig. 3.).

Fig. 3. – Adding the user column to the replacement object

Publish the object.

2. Create a replacement client module of the activity edit page

A replacement client module must be created and [Activity edit page] must be specified as the parent object in it (Fig. 4).

The process of creating the replacement page is described in the article Creating a custom client module schema.

Fig. 4. — Properties of the replacement edit page

3. Add the [Meeting Place] field to the activity edit page

Add to the diff array a configuration object with the settings of the [Meeting Place] field location on the page.

4. Add a rule with the BINDPARAMETER type for the [UsrMeetingPlace] column to the rules property of the page view model

5. Initialize the property property of the rule for the [UsrMeetingPlace] column using the BusinessRuleModule.enums.Property.VISIBLE value

6. Add a condition for the rule implementation to the conditions array — the [Type] field value of the model must be equal to the identifier of the [Visit] type specified in the activities type lookup)

Below is the full code of the replacement contact page.

// Add module BusinessRuleModule to the list of the module dependencies.
define("ActivityPageV2", ["BusinessRuleModule", "ConfigurationConstants"],
    function (BusinessRuleModule, ConfigurationConstants) {
        return {
            // Schema name of the edit page object.
            entitySchemaName: "Activity",
            // Setup of additional field visualization on the edit page.
            details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
            diff: /**SCHEMA_DIFF*/[
                {
                    // Metadata for adding the [Meeting place] field.
                    "operation": "insert",
                    "parentName": "Header",
                    "propertyName": "items",
                    "name": "UsrMeetingPlace",
                    "values": {
                        "layout": { "column": 0, "row": 5, "colSpan": 12 }
                    }
                }
            ]/**SCHEMA_DIFF*/,
            // Rule object of the edit page view model.
            rules: {
                // Rule set for the [UsrMeetingPlace] column of the view model. 
                "UsrMeetingPlace": {
                    // Setup of the visibility rule for the [UsrMeetingPlace] field by the
                    // [Type] field.
                    BindParametrVisibilePlaceByType: {
                        // BINDPARAMETER rule type. 
                        ruleType: BusinessRuleModule.enums.RuleType.BINDPARAMETER,
                        // The rule regulates the VISIBLE property of the field.
                        property: BusinessRuleModule.enums.Property.VISIBLE,
                        // Array of conditions that trigger the rule. 
                        // In this case the array contains single condition for [Type]
                        // comparing the [Type] column with the [Visit] activity type Id.
                        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: "Type"
                            },
                            // Type of the comparison operation.
                            comparisonType: Terrasoft.ComparisonType.EQUAL,
                            // Expression of the right part of the condition.
                            rightExpression: {
                                // The CONSTANT expression type points to the fact that a 
                                // constant expression is used (the [Visit] activity type Id).
                                type: BusinessRuleModule.enums.ValueType.CONSTANT,
                                // The value whith which the expression in the left part.
                                // is compared. In this case the [Activity] type Id is
                                // specified as a string.
                                value: "e3831dec-cfc0-df11-b00f-001d60e938c6"
                            }
                        }]
                    }
                }
            }
        };
    });


7. Save the created replacement page schema

When the schema is saved and the web-page of the system is updated on the activity edit page, the [Meeting Place] field will be displayed only if the activity type is Visit (Fig. 5, 6).

Fig. 5. — Demonstrating the case implementation result (the activity type is Call; no [Meeting Place] field is available).

Fig. 6. — Demonstrating the case implementation result (the activity type is Visit; the [Meeting Place] field is displayed).

 

  

© bpm'online 2002-2017.

Did you find this information useful?

How can we improve it?