Friday, February 12, 2021

How to Select Certain Records from a Set of Data in a Bubble App

 The Problem: Your company makes shoes and boots for men and women. You recently introduced a new all-weather boot called the "Sno-Boot" and you want to list all the customer comments on your website that deal with the Sno-Boot. Here's how to do that in Bubble...

Let's assume you have all your customer comments stored in a dataset on Bubble and that you have an input form where all the existing comments are displayed in a repeating group. To display just the comments concerning Sno-Boots:

  • Add two (or more) search boxes to the form. The reason for adding multiple search boxes is that you need to be able to search for "Sno-Boots" or any terms close to that, such as "snow boots", "Sno Boots", etc.
  • In this example let's say that you defined your customer comments as Data Type "customerComment", containing three fields: "custDate" (the date of the comment), "custProduct" (the shoe or boot that the customer is commenting about), and "custComment (the comment itself).
  • Double click the Repeating Group to display its Properties box and enter "customerComment" in the "Data type" field (since you're displaying records from the customerComment dataset).
  • In the "Data source" field do this:
    • Enter "Search for"
    • Select "customerComments"
    • Add a constraint: "custProduct" "contains" "Search box1's value".
    • Add a second constraint: "custProduct" "contains" "Search box2's value".
    • In the "Data source" field, following "Search for customerComments", add "merged with" "Search for customerComments".
Normally, if you have more than one search term, Bubble will look for records that have all the search terms. For example, if you entered "Sno-boots" in one search box and "snow boots" in the second search box, Bubble would look for records that contain both "Sno-boots" and "snow boots". By using the "merge" command between the two search terms, Bubble will search for records that have one term or the other, which is what you want.

No comments:

Post a Comment