Skip to main content
Version: 8.1

Set up filtering of lookup field values on a record page

Level: intermediate
Example

Set up filtering for contacts that can be selected after you fill out the Owner lookup field of the account page. Display the following in the contact selection box:

  • contacts linked to Creatio users
  • active contacts

Create a replacing view model schema of the account 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 "AccountPageV2."
    • Set Title to "Account edit page."
    • Select "AccountPageV2" in the Parent object property.
  4. Implement the filtering of lookup field values.

    To do this, set the attributes property for the Owner column:

    • Set the dataValueType property to LOOKUP. The value sets the column data type. The Terrasoft.core.enums.DataValueType enumeration represents the column data types.
    • Specify the configuration object of the lookup field in the lookupListConfig property.
    • Specify the function that returns the filter collection in the filters array.

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

    AccountPageV2
    define("AccountPageV2", [], function() {
    return {
    /* The name of the record page object's schema. */
    "entitySchemaName": "Account",
    /* The attributes of the view model. */
    "attributes": {
    /* The name of the view model column. */
    "Owner": {
    /* The data type of the view model column. */
    "dataValueType": Terrasoft.DataValueType.LOOKUP,
    /* The configuration object of the LOOKUP type attribute. */
    "lookupListConfig": {
    /* The array of filters to apply to the query that populates the lookup field with data. */
    "filters": [
    function() {
    var filterGroup = Ext.create("Terrasoft.FilterGroup");
    /* Add the "IsUser" filter to the resulting filter collection.
    Select all records with non-null [Id] from the [Contact] root schema to which the [Id] column from the [SysAdminUnit] schema is joined. */
    filterGroup.add("IsUser", Terrasoft.createColumnIsNotNullFilter("[SysAdminUnit:Contact].Id"));
    /* Add the "IsActive" filter to the resulting filter collection.
    Select all records for which Active=true from the [Contact] root schema to which the [Active] column from the [SysAdminUnit] schema is joined. */
    filterGroup.add("IsActive",
    Terrasoft.createColumnFilterWithParameter(
    Terrasoft.ComparisonType.EQUAL,
    "[SysAdminUnit:Contact].Active",
    true));
    return filterGroup;
    }
    ]
    }
    }
    }
    };
    });
  5. Click Save on the Designer's toolbar.

Outcome of the example

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

As a result, Creatio will filter contacts on the account page when you fill out the Owner lookup field.

For example, you cannot select the Andrew Z. Barber contact in the Owner lookup field on the account page because the contact is inactive.

You cannot select the Sheldon Mallen contact in the Owner lookup field on the account page because the contact is not linked to a Creatio user.


Resources

Package with example implementation