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.

image0

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 Features > Add Table Filter, then configure the filter:

  • Filter Type: Select Option
  • Filter Method: Server
  • Pick Options and Condition(s): Manually
  • Model Condition to Affect: The condition created (above).
  • Show Label Above Filter: Yes, use Custom label.
  • Filter Label: Sort by City
  • Create “None Selected” Option: Checked
  • “None Selected” Option Text: Select City

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 fa-plus-circle 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}}}