Hi!
It seems Bubble is executing backend steps in workflow asynchronously and doesn’t wait for the previous step to complete. This leads to problems when I need to overwrite data used on a previous step.
The question is how can I synchronize front-end steps and backend steps in a way that a backend step is triggered at the right moment?
For now I use scheduled custom events with delays of a few seconds. But this seems like an unreliable and simply bad ux.
Example with my latest problem
I’m making a messenger app and when user opens a chat I have a step Scroll to first of “unread” messages. To find unread I have a field “Viewed by” in the message thing to keep a list of users who have seen the message. So if there’re messages where this list doesn’t contain current user I scroll to the first of the list:

Then follows a step that adds current user to the list “Viewed by”.
The problem is that while the app loads the message list and gets to the “Scroll to…” step the “Viewed by” field is already changed so the condition for the scroll is not met.
Thanks!
Use custom workflow triggers. Whatever actions you need to have completed before another subsequent action should be in the custom workflow trigger, then you trigger it in the series, followed by the actions you want to happen only after the actions in the custom trigger are completed.
Hello @boston85719 ! Thanks for your reply!
Actually I’ve tried custom events but it also turned out to be unreliable - in the example in my post it just didn’t work. When I put this step into trigger custom workflow the problem remains. I had to put a scheduled trigger.
This is how the workflow looks like (last step is custom event)
What troubles me the most is that I don’t feel confident when I am doing these very simple things. Even if something works ok in my browser on test data it doesn’t mean it will work later in other browser or when there is more data in the app. And I don’t even know a way to test it, because step-by-step debugger is not following the steps consquently either 
Simple fix to this specific issue would be to not automatically scroll to the last unread message and remove the read.
In my chat applications I make it so the user will see a list of conversations just like you would on iOS, then when they click into a conversation, I change the ‘read’ because it is easy to say when the user clicks the conversation, show the list of messages in the conversation and mark all as read.
Well yeah I understand that there’re some workarounds, but this was more of an example. It’s just not the first time that I run into this situation and it’s really frustrating. Thank you!