Skip to main content
Version: 8.1

Set up the display conditions of a field on a record page

Level: intermediate
Example

Set up the display conditions of the Meeting place field on the activity page. Creatio must display the field for activities with the "Meeting" category, i. e., the activities that have "Meeting" selected in the Category field.

1. Create a replacing object schema

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

  2. Click AddReplacing object on the section list toolbar.

  3. Fill out the schema properties.

    • Set Code to "Activity."
    • Set Title to "Activity."
    • Select "Activity" in the Parent object property.
  4. Add a column to the schema.

    1. Click add_button in the context menu of the object structure's Columns node.

    2. Click TextText (250 characters) in the drop-down menu.

    3. Fill out the properties of the added column.

      • Set Code to "UsrMeetingPlace."
      • Set Title to "Meeting place."
  5. Click Save then Publish on the Object Designer's toolbar.

2. 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 "ActivityPageV2."
    • Set Title to "Activity edit page."
    • Select "ActivityPageV2" in the Parent object property.
  4. Add a localizable string.

    1. Click the button in the context menu of the Localizable strings node.

    2. Fill out the localizable string properties.

      • Set Code to "MeetingPlaceCaption."
      • Set Value to "Meeting place."
    3. Click Add to add a localizable string.

  5. Add the BusinessRuleModule and ConfigurationConstants modules as dependencies to the declaration of the view model class.

  6. Set up the field display conditions.

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

      1. Set the ruleType property to BINDPARAMETER. The value sets the business rule type. The BusinessRuleModule.enums.RuleType enumeration represents the rule types.
      2. Set the property property to VISIBLE. The value sets the column visibility. The BusinessRuleModule.enums.Property enumeration represents the properties of the BINDPARAMETER business rule.
      3. Specify the execution conditions of the business rule in the conditions array. The ActivityCategory column value must match the ConfigurationConstants.Activity.ActivityCategory.Meeting configuration constant that includes the ID of the "Meeting" record of the Activity types lookup.
    2. Add a configuration object with the settings that determine the layout of the Meeting place field to the diff array of modifications.

    View the source code of the replacing view model schema of the activity page below.

    ActivityPageV2
    /* Specify the BusinessRuleModule and ConfigurationConstants modules as dependencies. */
    define("ActivityPageV2", ["BusinessRuleModule", "ConfigurationConstants"], function(BusinessRuleModule, ConfigurationConstants) {
    return {
    /* The name of the record page object's schema. */
    entitySchemaName: "Activity",
    /* Display the field on the record page. */
    diff: /**SCHEMA_DIFF*/[
    /* The properties to add a [UsrMeetingPlace] field to the record page. */
    {
    /* Add the element to the page. */
    "operation": "insert",
    /* The meta name of the parent container to add the field. */
    "parentName": "Header",
    /* Add the field to the parent element's collection of elements. */
    "propertyName": "items",
    /* The meta name of the field to add. */
    "name": "UsrMeetingPlace",
    /* The properties to pass to the element's constructor. */
    "values": {
    /* Bind the field caption to the localizable schema string. */
    "caption": {"bindTo": "Resources.Strings.MeetingPlaceCaption"},
    /* Set up the field layout. */
    "layout": {
    /* The column number. */
    "column": 0,
    /* The row number. */
    "row": 5,
    /* The column span. */
    "colSpan": 12
    }
    }
    }
    ]/**SCHEMA_DIFF*/,
    /* The business rules of the record page's view model. */
    rules: {
    /* The set of rules for the [UsrMeetingPlace] column of the view model. */
    "UsrMeetingPlace": {
    /* The visibility of the [UsrMeetingPlace] field depends on the [ActivityCategory] field value. */
    "BindParametrVisibilePlaceByType": {
    /* The BINDPARAMETER rule type. */
    "ruleType": BusinessRuleModule.enums.RuleType.BINDPARAMETER,
    /* The rule that controls the VISIBLE property. */
    "property": BusinessRuleModule.enums.Property.VISIBLE,
    /* The array of conditions that trigger the rule. Check whether the [ActivityCategory] column value is "Meeting." */
    "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": "ActivityCategory"
    },
    /* Set the comparison operation type to equal. */
    "comparisonType": Terrasoft.ComparisonType.EQUAL,
    /* The right side expression of the condition. */
    "rightExpression": {
    /* Set the expression type to constant. */
    "type": BusinessRuleModule.enums.ValueType.CONSTANT,
    /* The value to compare to the left side expression. */
    "value": ConfigurationConstants.Activity.ActivityCategory.Meeting
    }
    }]
    }
    }
    }
    };
    });
  7. Click Save on the Designer's toolbar.

Outcome of the example

To view the outcome of the example:

  1. Refresh the Activities section page.
  2. Select "Meeting" in the Category field of the activity page if needed.

As a result, Creatio will display the Meeting place field for activities that have the "Meeting" category.

Creatio will not display the Meeting place field for other activity categories. For example, "To do."


Resources

Package with example implementation