Hey. Is it possible to trigger an event as soon as a piece of data has changed? So far I have only managed to get it to work once the page is refreshed. Is it possible to have the page check it every so often without refreshing the page?
You can look into “Trigger custom event when data changes” which watches a field in the database for a change during the current page session. It only triggers the event once though, so you’d need to run the action again if it needs to “re-watch” for the change. Check out these video for a bit more on that feature:
Also, depending on what you’re doing, you can also take a look at the “Do When” workflow event that has a run “every time” or run “only once” option. Hope this helps!
@romanmg Thanks, Gaby! Really liked your idea of the loop when creating the custom events !
I’ve been trying to implement a version of this, but something isn’t working. Would hugely appreciate any input.
I’ve created a test app just to show this issue. In this case, each user has a user number (1,2,3…). A separate data type (called Counter) has a field called CounterNumber which is incremented by 1 each time a button is pressed.
Essentially, I’m trying to get a message to pop up when the CounterNumber equals the Player Number - so that only the user that matches the counternumber will get the pop up. I’ve put this as a condition on the Pop up action.
I can get it to work on pageload/refresh, but not otherwise. Do you know what I’m doing wrong?
For anyone trying to replicate Gaby’s example, here is some information from Bubble support…
- Database change triggers are only available on paid plans. Since this app is on the Hobby plan, the feature will not work as intended
- DB change triggers cannot trigger workflows that trigger another DB change trigger. In this case, the DB change trigger is used to trigger a custom event that also uses one. This will also produce unintended behavior
In particular, the second point seems to say that Gaby’s solution won’t work consistently and isn’t supported.
If anyone has a different way of triggering pop ups on another user’s screen, I’d be interested to hear about it.
I was looking for something similar and this is what I am thinking…
Add a state for Count of the table “A”. So when the count of this table “A” is changed - is more/less than this state - trigger the event.
Can we create a custom event to change the value of a state whenever a new element is added to the database ?
Thank you for sharing the video. Want to ask can we acheieve the same thing with two different pages.
I have created the custom event on one page which i want to access in another page or reusable element. Coz the way you are trigering it on button click, i want to make it on chnage of dropdown value.(The dropdown is in a reusable header element, so thats why i’m not able to trigger the event from that page itself.)
Do you have any idea on how to achieve this ?
Hi @romanmg and thank you for sharing these tutorials.
I have 2 questions regarding this topic:
- When should you use a “do when condition true” instead of the trigger event
- Is it normal that a current_date is not accessible inside a custom event ? I also noticed that when my custom event is triggered, the debugger can’t access the current_user data while it’s still seem to gather its informations outside of the debugger…