Data Filter Examples

When working with data repeaters, data tables, and data functions, you can filter the data you retrieve in many ways. In this topic, we explore two options— fixed values and URL query strings—to illustrate some common filtering techniques.

Required Editions

Available in: Salesforce Classic

Available for purchase in: Enterprise, Performance, and Unlimited Editions

Available (with limitations) in: Developer Edition

Example 1: Use a Fixed Value to Filter Results

In our first example, we have a custom object called “News” that stores company news and events. Each news item has a Status picklist that can be set to either In Progress or Approved. We only want to display approved news items on our Company News page. In this case, we can use a fixed value to filter the data in the News object.

In this scenario:

  1. Add a data repeater to the page and configure it as follows:
    1. Select the News custom object.
    2. In the Filters section, set the criteria to Status Equals Fixed value.
    3. Enter Approved in the Value text box.
    This configuration tells the data repeater to return only records where the Status field contains the value Approved.
  2. To display the required fields, such as Title, Description, and Date, on the page, add data elements to the data repeater.

Example 2: Use a URL Query String to Dynamically Filter and Display Results on Another Page

In our second example, we have a custom object called “Products” that stores product information. However, some products are only available in certain locations, so we like to let customers view the products in their nearest city. In this case, we could create a Locations site page that contains links to each available city.

We want each link to open the Products site page, but only display products based on the user's selection. We can do this using URL query strings, which let us pass variable content between HTML pages. The variable information in this case is the product location; the data repeater doesn’t know which products to return until the user makes a selection.

In this scenario:

  1. Add a data repeater to the Products page and configure it:
    1. Select the Products custom object.
    2. In the Filters section, set the criteria to City Equals URL query string.
    3. In the Value text box, enter the variable name—in this case, location.
    4. If query string is missing dropdown list, select Don't apply this filter item. This option is used when a customer wants to view all products without filtering.
    5. Click Save.
  2. Add data elements for the fields you want to display, such as Product Name, Description, and Price.
  3. On the Locations page, add a data repeater and select the Products custom object.
  4. Add a data element to the data repeater to represent the City field and configure it:
    1. Select the City field as the field to display, because we want to use the name of the city as the hyperlink.
    2. Select Text as the display format.
    3. Select Add a hyperlink to display a URL on the page.
    4. In the Link to dropdown list, select An item in your site.
    5. Select Page as the type and select the Products page. (If you can't see the list of pages, place your cursor in the URL text box and press the DOWN key on your keyboard.)
    6. Change the URL value to /product?location={!City}. In this case, {!City} is a placeholder for the value of a record's City field. When the page first loads, {!City} is replaced with the correct value, such as Dallas, which creates this URL for that record:
      /product?location=Dallas

      When clicked, the Products page opens with Dallas listed as the value of the location variable.

    7. For the tooltip, select the City field and click Customize.
    8. Change the value to Show me products available in {!City}.

      Again, the value of the City field replaces the {!City} placeholder for each record when the page loads.

Now, when the Locations page loads, the data repeater displays the location of each product as a link. When a customer clicks a link, such as Dallas, the Locations page passes location=Dallas to the Products page. As the Products page loads, the data repeater uses this value to dynamically return only records where the City field contains the value Dallas.