Use Select Option with Multiple Conditions and Fields

Imagine a Table component that displays data on sales opportunities. The sales reps using the page want to filter for three different things—represented by three different fields:

  • Their assigned leads—the ones they “own” (an OwnerID field)
  • The records they have updated (a LastModifiedById field)
  • All records updated within a certain period, for example, “this month” (a LastModifiedDate field)

Here’s how to use multiple conditions to give users all these options on a single filter dropdown.

The goal? A filter that allows the user to select from a dropdown of pre-selected options to filter leads to display either:

  • Those the user owns
  • Those modified by the user
  • Those modified within a specified time frame

image0

Assumptions

Note

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

  • a Table component that model with fields for:

    • Name
    • Amount
    • Close Date and Last Modified Data
    • Last Modified by ID and Owner ID

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

Create model conditions [[]]

Create three separate conditions, one for each option.

The record owner condition

  • Field: The field that records the record’s owner: OwnerId

  • Operator: =

  • Value:

    • Content: The Skuid/Salesforce/Data source user attribute. (The correct option depends on the data source used.) This identifies the user accessing the data.
    • User Attribute: User Id
  • State:

    • Condition State: Filterable Default Off. (Skuid will automatically generate a name for the filter.)

The modification condition

Duplicate the steps taken for the last condition, but use a field that records who modified the records (for example, the object’s LastModifiedById field.)

All other properties are the same.

The modification date condition

This filter is a little different, since it uses a datetime value.

  • Field: The field that records who modified the records: LastModifiedDate

  • Operator: =

  • Value:

    • Content: Single Specified Value
    • Value: Select the desired value from the picklist, for example, This Month, or This Week.
  • 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: None
  • Show Label Above Filter: Yes, use Custom label.
  • Filter Label: Sort my leads
  • Create “None Selected” Option: Checked.
  • “None Selected” Option Text: Sort by …

Add filter sources [[]]

Now, identify the sources for the filter’s dropdown menu options. On the Choose amount filter, click fa-plus-circle Add Option Source, then configure:

  • Source Type: Manual

The filter needs three filter options (one representing each condition created in the first step).

First filter option (“Records I own”)

On the Source: Manual option source, click fa-plus-circle Add Option, to create an option for the first item in the filter. Then configure:

  • What Conditions will this Option affect?: Affect Other Condition(s). You don’t want to activate any default conditions, but instead activate one of those that you created specifically for this filter.
  • Label: Owned by Me
Add effects to the option

Click fa-plus-circle Add Effect and configure:

  • Action: Activate

    Note

    Do not use Activate and Set.

  • Model Condition: The condition created earlier for the record owner.

Second and third filter options

Repeat the steps above to add two additional filter options and their effects:

  • One with an option label of Modified by Me with an effect that activates the model condition about who modified the record.
  • Another with an option label of Last Modified with an effect that activates the model condition about when the record was modified.