Hi all. I’m stuck and seem to be in a loop.
I’m creating an feature that allows products to be ranked 1-3 at 23:59 everyday, and create an award for those ranked products.
Where I’m stuck? I created an API WORKFLOW (product list= Do a search…) and mase necessary changes to the products.
I am unable to do the below:
Schedule the workflow to run daily
Identify their index (to know the first, second and third)
I’ll appreciate any help. Can provide images if necessary.
ruiz86
April 6, 2025, 2:21am
2
You have several ways to accomplish what you want:
Two Recursive Workflows
In the Backend Workflows tab, create an API Workflow with these parameters:
product : List/array (check the box)
index : Number
count : Number
Image
Step 1: Configure the Main Action
Create a “Make Changes to a Thing” action to modify the item at the current position:
Select product: item: #index
Configure the field you want to change
Image
Step 2: Set Up Recursion
Schedule the same API Workflow you’re creating:
product : Use the same “product” parameter
index : Set to “index + 1”
count : Keep the same “count” value
Schedule Date : Current date and time
Condition : Only run when “index < count”
Image
Step 3: Configure Re-scheduling
Schedule the same API Workflow again:
product : Do a search for the products you want to modify
index : 1 (to restart)
count : Do a search for the products and use the “count” function
Schedule Date : Current date and time + 1 day
Condition : Only run when “index = count”
Image
Step 4: Configure Frontend Trigger
In the Frontend Workflow tab, set up the initial trigger:
Schedule the API Workflow you created
product : Do a search for the products you want to modify
index : 1 (starting position)
count : Do a search for the products and use the “count” function
Schedule Date : Current date and time: change hour to 23, change minute to 59, change second to 0.
Image
Alternative Method Using Recurring Events
Instead of Step 3 in the original approach, you can use a Recurring Event:
Step 1: Create a Recurring Event
In the Backend Workflows tab:
Create a new Recurring Event
For “Type of thing”, select the datatype associated with the recurring event (e.g., User)
Image
Step 2: Configure the Recurring Event
Inside the Recurring Event, create a “Schedule API Workflow” action:
Select the API Workflow you created earlier
Configure the parameters:
product : Do a search for the products you want to modify
index : 1 (starting position)
count : Do a search for the products and use the “count” function
Schedule Date : Current date and time
Image
Step 3: Set Up the Frontend Trigger for Recurring Event
In the Frontend Workflow tab:
Create a “Set/Cancel a recurring event” action
Select the Recurring Event you created in the Backend
For “Workflow thing”, select the appropriate item (if you used User as datatype, you can use Current User or another user)
Set Frequency to “daily”
Set Start Date and time to: Current date and time, but change hour to 23, minute to 59, second to 0
Image
Note : Some types of recurring events may not be available depending on your Bubble.io subscription plan.
Be mindful of privacy rules to ensure that the executed Workflows will be able to access all the necessary data to make the changes you want.
There is also an approach using Schedule API Workflow on a list. Depending on your case, this approach might be even more suitable.
Another Approach Using “Schedule API Workflow on a List”
Step 1: Create the Worker Workflow
Create an API Workflow (this will be “Step 2”) with the parameter “product”
Inside this workflow, add a “Make changes to product” action with the modifications you want to make
Image
Image
Step 2: Create the Scheduler Workflow
Create another API Workflow (this will be “Step 1”)
Inside this workflow, add a “Schedule API Workflow on a list” action with:
Type of things: “product”
List to run on: Do a search for products (the list you want to process)
API Workflow: Select the “Step 2” workflow you created earlier
Schedule date: Current date/time
Product: This product
Add another “Schedule API Workflow” action and select this same API Workflow (Step 1)
Schedule date: Current date/time + 1 day
Image
Image
Image
Step 3: Set Up the Frontend Trigger
In the Frontend Workflow tab:
Create a “Schedule API Workflow” action
Select the “Step 1” workflow
Schedule date: Current date and time, but change hour to 23, minute to 59, second to 0
Image
Regarding which approach to choose, I recommend reading this guide:
Thank you very much.
Well explained, and it worked for me. I used first step, as it lets me save the #index , and attached to the award I’m creating for the products daily.
Much appreciated
1 Like
Hi !
It’s not very clear on what principle you are organizing the products.
But as an option, I would suggest -
Create a reccuring event in Backend WF
Create a separate data type Ranked Products with fields (First product, Second product, third…).
In the reccuring event, create an action - Create/modify a Ranked Products (depending on the functionality required) and in it change these fields:
First product = Do a search for products: sorted/filtered :Item #1
Second product = Do a search for products: sorted/filtered :Item #2
Third product = Do a search for products: sorted/filtered :Item #3
Create a draft button on any page on which you set event - “Set reccuring event” / daily. It is not necessary to send a value to it in this case. If you need it at 23.59, then in the Start date field - current date/time: change hours to 23 : change minutes to 59.