How to 'cycle' through list of quotes in one text box?

So i’m trying to rotate through a list of quotes on a loader screen. I have a text box with one quote, but want to conditionally render all of my quotes (10). Is there a way to do this from the element itself or through the workflow?

Hi @micah :slight_smile: Definitely! One simple method is to use a popup as the loading screen, and set the popup’s type to “Quote”. Then, set the data source to:
Do a search for Quotes: random item

This will make sure a random quote is shown each time the loading screen is shown:

One downside to that approach is it won’t necessarily cycle through all 10 different quotes before showing the same one twice. If you do want to make sure that all quote are cycled through one-by-one, one approach would be to add a field on the User data type called “Quote number” (type: number, list: no):

Then, set that field’s default value to “1”:

In contrast to the simple method of using “Do a Search for Quotes: random item”, the data source expression for this method would instead be:
Do a Search for Quotes: item # Current User's quote number.

Then, you’d just need two different workflows to make sure the User’s “quote number” field for the Current User increments by 1 each time the loading popup is shown, as well as a workflow which ‘resets’ the field value to 1 when the User’s Quote number is greater than or equal to the total number of Quotes in the database. Here are the two workflows:

  1. Event: When the loading popup is opened and Current User’s Quote number is less than Do a Search for Quotes:count →

    (Do a Search for Quotes:count is always equal to the total number of Quotes that you have in the app’s database)

Action: Make Changes to the Current User, field to update: Quote number = Current User's quote number + 1 (This action makes sure the ‘next’ quote will be shown when the loading popup is displayed again)

  1. Event: When the loading popup is opened and Current User’s Quote number is greater than or equal to Do a Search for Quotes:count

Action: Make Changes to the Current User, field to update: Quote number = 1 (This resets the Current User’s Quote number field value back to 1, so the first quote will be shown again when the loading popup is visible).

That should work, but feel free to let me know if you have any questions! :slight_smile:

7 Likes

Thank you for the response! One thing I’m trying to figure out is where to store the quotes. Could this be done in a conditional statement of the popup?

No problem at all! :slight_smile: Using that setup, the quotes would be stored in the database. For example, you could create a data type called “Quote” and then have a single field called “Text” (type: text, list: no) which stores each Quotes text.

Then in the App Data tab, you can create these 10 different Quotes as new entries (i.e., new “rows” in the Quotes table).

Doing this will allow you to use the “Do a search for Quotes: item # Current Users quote number” or “Do a search for Quotes: random item” options since “Do a search for” searches through all of the Quotes that are stored in the database, and retrieves a single one. I’m sorry I would share better screenshots but I’m on mobile at the moment; please let me know if you have any questions as you set it up!

3 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.