Data Filters for Dynamic Choice Lists

When creating a custom dynamic choice list, also known as a list of values, you can filter the values that display in the list at runtime. For example, set up a simple filter to show only a subset of records in the list.

Understanding Data Filters

When you first define a dynamic choice list, you indicate which related object's records populate the custom field's list of values. You can further refine the set of data that appears within the dynamic choice list at runtime by using data filters. Ideally, set data filters on a dynamic choice list during the initial configuration of the field.

To refine the set of data that appears within the dynamic choice list, select from one of three options:

  • Simple mode

  • Advanced mode

  • Existing filter

Tip: When defining a simple or advanced filter, use indexed fields to optimize performance.

Defining Simple Data Filters

A simple data filter uses static values that you provide as search criteria to refine the list of values at runtime. For example, when editing an opportunity, the list of accounts that display in the Account dynamic choice list can be filtered to show only active accounts.

To define a simple data filter:

  1. In Application Composer, create a custom dynamic choice list field.

  2. After you select the related object and the object's field that you want to display in the list of values, navigate to the Data Filter region.

  3. In the Data Filter region, click Add Search Field.

  4. Select the field that you want to use as the simple filter, then specify the criteria to apply at runtime.

    For example, if you select City, then specify a city name, such as New York.

    You can select more than one field.

  5. Complete the rest of the field's configuration, then click Submit.

The filter's static value is applied to the set of records in the dynamic choice list at runtime to refine the list of values.

Defining Advanced Data Filters

An advanced data filter uses dynamic criteria based on the object context to refine the list of values at runtime. As part of the advanced data filter, you can write Groovy expressions and accept bind variables.

To define an advanced data filter:

  1. In Application Composer, create a custom dynamic choice list field.

  2. After you select the related object and the object's field that you want to display in the list of values, navigate to the Data Filter region.

  3. In the Data Filter region, click the Advanced Mode link that displays in the instructions.

  4. Enter a search expression to refine the records that appear in the list of values. As you write your script:

    • Click Add Search Field to select appropriate fields.

    • Click Add Bind Variable to pass the target object context to the filtering expression.

      For example, when editing a lead, the list of campaigns that display in the Campaign dynamic choice list can be filtered by adding bind variables that pass context from the lead record to the Campaign dynamic choice list.

  5. Check the When filtering data, ignore expressions involving null bind variable values check box.

    This check box defines the behavior of the expression when a bind variable evaluates to null.

    • If this box is checked, then any atomic expression ("FieldName Operator Operand") whose bind variable evaluates to null is ignored. The other atomic expressions that are part of the filter remain.

    • If this box isn't checked and the bind variable evaluates to null, then the dynamic choice list will be empty.

  6. Complete the rest of the field's configuration, then click Submit.

Caution: Don't define advanced data filters if you're working with a dynamic choice list that's based on one of these objects:That's because these objects have corresponding search and select dialog boxes that you can configure. Instead of defining data filters, prepopulate the field's corresponding search and select dialog box with the records you want your users to see first. See the related topic, "Prepopulate a Search and Select Dialog Box with Default Values."

Using Existing View Criteria Filters

When defining a data filter for a dynamic choice list, you can select from a predefined list of existing view criteria filters. These existing filters are the named view criteria that are already provided for some standard objects. Some standard objects may predefine named view criteria which you can use to simplify common searches.

To select an existing view criteria filter:

  1. In Application Composer, create a custom dynamic choice list field.

  2. After you select the related object and the object's field that you want to display in the list of values, navigate to the Data Filter region.

  3. In the Data Filter region, click the Existing Filter link that displays in the instructions.

  4. Select the desired filter.

  5. Complete the rest of the field's configuration, then click Submit.