Use Select option with Builder-generated Options

Unlike picklist fields, which have a defined set of values, string fields have values unique to each record—for example, the list of cities where accounts are listed. To create a filter that includes all the unique values (without displaying duplicate values) for a string field, you need to pull those values together using an aggregate model.

Let’s create a model that allows users to filter sales opportunities by the city in which the opportunity is located.

The goal? A filter that allows users to select from a list of string values, in this case, the city associated with the account.

image1

Assumptions

Note

The example below assumes a Skuid page with:

  • a functioning model on an object that collects opportunity data. (In this example, we use Salesforce’s Opportunity object).

  • a Table component that model with fields for:

    • Name
    • associated account, i.e. AccountID
    • Amount
    • Billing City

If using a different data source, the field names indicated may be different.

Create model conditions [[]]

  • Field: The field that contains the record’s city: BillingCity.

    Note

    Some opportunity objects do not include a field for city, but do include a city field for the account itself. In the fields list, click fa-arrow-circle-o-right next to the account ID field to open the associated fields on the account object. Then select the appropriate “city” field.

  • Operator: =

  • Value: Leave blank

  • State:

    • Condition state: Filterable default off. (Skuid will automatically generate a name for the filter.)

Build the filter [[]]

On the Table component, click Add feature > Table filter, then configure the filter:

  • Filter type: Select option
  • Filter method: Server
  • Pick options and condition: Manually
  • Filter label: Filter by City
  • Model condition to affect: The condition created (above).
  • Create “None Selected” option: Checked
  • “None Selected” option text: Select City
  • Display as: Dropdown

Create an aggregate model [[]]

Create a new aggregate model on the same object you want to filter, in this case, an Opportunity object. By aggregating on the object’s data, the model creates a list of all the unique values used within the field, without duplicating any of those values. We then use this unique values list as the source for the filter.

In the model, leave the Max # of records property blank.

Group the model

Under Groupings select the Simple Grouping method. Then select the field to group by using the same field employed by the condition–Billing City. Once created, click that grouping item, and copy its Alias name from the properties pane. (You’ll need this for the filter source.)

Note

Aggregate models cannot be grouped by formula fields.

Add filter sources [[]]

It’s time to identify the source for the filter’s menu options, so click the filter, then click add Add option source, then configure:

  • Source type: Rows in a model
  • Merge source: Choose the aggregate model just created
  • Option label template: Instead of selecting the field from the field picker, use the Alias Name copied from the grouping. Enclose this name in triple curly brackets, like this {{{alias.name}}}
  • Which conditions will this source’s options affect?: Just the default condition
  • Value to inject into default condition: Again, use the Alias Name enclosed in triple curly brackets: {{{alias.name}}}