Hi there.
I’m trying to create a workflow to update things based on values from other things.
The use case is as follows.
I have 3 databases:
Users - contains users and each user has a list of bets
Bets - contains an entry for bets
Events - contains football matches
Before the match starts, I’ll add an event to the DB. Then users can place a bet. Each match contains fixtures_id which should allow to uniquely identify the match within the events.
But when the match is over I need to update each bet to assign points:
3 points if the bet matches the exact score
1 point if bet matches only the winning team
How can I update all bets in bulk?
So my idea was to iterate through all bets and match them based on fixtures_id and points assignment limits using only_when field, but this does not allow me (or I don’t know how) to set condition to match bet with events.
Well it depends on your implementation. (the devil is always in the detail).
So for a start you want to index the bets table by the Fixture type rather than the fixture id. This is counter intuitive if you are used to traditional database structures. But it is the most optimal and flexible way of doing it.
It might then have to be 2 stage:
From your events return the Fixture you need (Do search for the fixture you need based upon your Events criteria)
Pass that Fixture in to the query to get the Bets you want to update. And then away you go.
You could this in the same workflow, or you could split in to a backend WF and frontend workflow depending upon the details.
What do you mean? I don’t see an option to make a query other then update. Do you mean make changes to … without actually changing anything just to get a list of fixtures as part of step x?
OK it sounds like you are missing some knowledge on retrieving (searching) data from your table.
The manual is a good place to start, and there are thousands of videos out there by bubble developer, which will give you something to learn by example from.
This page here will show you how to retrieve data:
What you need to be doing is to first query (search) your events table for to the correct Fixture. You then return that from the search and then take that in to the next stage where you do the actual Make changes.
I not quite follow how the flow should looks like. I though I can do everything within the workflow.
Let assume that user will click the button to trigger action. Button itself didn’t do any lookup. It can only start a workflow. What should trigger the lookup (or retrieving data from Events type)?
I only know what I want to achieve but I can implement any solution available.