Hi all - I’m looking for help and have been stumped for quite some time on this issue. I’ve read everything I can in relation to order of operations for workflows and how to best handle sequential workflow needs, but am stuck on an issue that is causing duplicate issues in my DB.
I have a custom event that creates a thing if it doesn’t exist in the DB or makes changes to it if it does exist. As part of my larger workflow, I need to trigger this custom event multiple times (see screenshot) where I pass different parameters to it as needed.
This custom event then creates or makes changes to the thing as needed (see screenshot).
The problem I’m having is that triggering this event multiple times will create multiple items in the DB because they are all running at the same time (or very close to the same time) per the standard Bubble workflow order of operations design and the search that tells the workflow if the item already exists does not update in real time (again per the standard Bubble workflow order of operations design).
I’ve tried every variation of custom events, custom events inside other custom events, conditionals, custom event return values, etc. and cannot figure it out. I thought custom event return values would allow me to reference “previous step of” type design and delay the triggering, but I could not get it to work.
The only thing that works is if I schedule the custom events instead of triggering them, but I know I do not want to do this because that will then have them running in parallel to remaining items in the larger workflow which can cause different issues for my order of operations.
Furthermore in the below 2 steps of one of your custom triggers (I say one of them since the first screen shot shows Monthly Totals - Written and Monthly Totals - Issues and it is assumed they are different custom triggers) there is no conditional on the make changes to thing in step 1. This by itself likely is not the reason for duplicate entries created, but is a waste of WUs because it will run even when it should not, so you should have a conditional on it to be the opposite of whatever the conditional you placed onto step 2 of Create New Monthly Totals.
Please expand on why that is the case.
Based on what you provided in the post, it seems like the problem is not order of operations of Bubble workflows but a lack of conditionals and a seemingly unnecessary running of the same actions twice (that is step 6 and 8 of triggering same custom trigger twice).
Without knowing for sure that Monthly Totals - Written is different trigger from Monthly Totals - Issued it is hard to say how to alter your current setup…but if I were to need a function to make changes to something if it existed or to create something if it doesn’t I would do the below.
Setup a custom trigger for Creating a New Thing and a custom trigger for Modifying an existing thing.
In the workflow series I would trigger the custom trigger to modify an existing thing and have a conditional to trigger only if the thing exists, then I would have the custom trigger for create a new thing and conditionals to run only if the thing doesn’t exist. When I run the trigger to make changes to the thing, I would update all fields required in the one step and the same for creating a new thing, I’d update all fields in the one step.
I did previously have conditionals on both of those steps, but likely did not change them back during various testing and changes trying to resolve the issue.
You are correct that it should be changed back as the first item always does a search and as you said is a waste. The second step with conditional currently says to run and create the item if step 1 was empty.
In regard to running 6-8, they are being passed different parameters for different reasons related to complex math calculations, different date ranges, etc. so they do all need to run each time.
Your suggestion is mostly what I was trying to avoid as it really bloats the amount of custom events in play as I have multiple variations of the make changes or create item workflows all with different fields and settings. I’m also not sure that would even solve the issue as they all still will need to trigger and run independently. And yes, Monthly Totals - Written and Monthly Totals - Issued are different and step 8 is different despite calling Monthly Totals - Issued again.
In simplest terms, what is happening is steps 6-8 all trigger at the same time per Bubble design and each one of those workflows will do a search, see the item doesn’t exist, and create the item. All three of these trigger at the same time, thus three items created.
I believe the biggest issue I am having is that searches are not updated immediately as Bubble has described in their order of operations documentation, but I have no good way to chain “result of” type items between different custom events, especially when I am regularly doing searches for existing items and not always creating new items.
That is not the case. When a custom workflow is triggered, subsequent workflows in the series do not trigger until all actions in the custom workflow first triggered are completed.
That is not the case most likely, and it is likely creating 3 because of conditionals not set properly
They are updated immediately…the only times there are issues with searches not updating immediately is when a search is done in an RG as the datasource and changes to the database are not displayed in the RG instantly…in your case, you are not having issues with searches in an RG.
In your case, when you run an action that performs a search the search is done at that moment and would return the most up to date information in the database.
I think you do not quite understand my suggestions. Mostly I was trying to help you focus on the need to have proper conditionals for when to create something and when to make changes to something. In your setup you have done that improperly.
Please elaborate on that as in my experience I have not needed to run in sequence two different make changes to a thing to update different field values, and instead I only need a single make changes to thing and I update the field values necessary…your situation may lead to further changes needed on your UI/UX as well to make sure things are done optimally as the way in which you setup the UI/UX can affect whether or not you can run a single make changes to thing action and have all data saved correctly.
This is not a conditional issue and while Bubble says this is how custom events work, there are many, many instances in the forum where that has been disproven. Not disproven that they don’t run one after another, but that they often run within 1 millisecond of each other causing timing issues such as mine.
If I schedule this custom event even with a zero second delay, it works fine and does not create the duplicates. This further proves it’s just a timing issue and this is why Bubble says searches are not updated in real time and to use result of type functions to be safe. If they were, my search for said item would not be empty, thus the create new item task (which has a conditional of “if make changes to thing is empty”) would not run, let alone run three times creating three items.
I’d have to spend a lot of time explaining the intricacies of my app (it’s very complex) to answer some of your questions which I am not going to do for timing sake, but I do appreciate your response.
Closing the loop - support was also unable to help here, but I believe I’ve just figured it out using chained return values from various custom events to ensure completion of the prior event before starting the next event. I can now ensure sequential work where I need it.
I would have loved to share more info, especially since I was asking the community for help, but my app does significant revenue in a highly competitive space, and I am extremely protective of it.
Glad you got to this point and resolved the issue.
Hope the solution is not bloating your custom events.
I would just recommend in future to take an approach of attempting things suggested rather than focusing on what you do not want to do, as it can lead to a significant lag time in completing a feature and fixing something. You could have gotten there 10 days ago…but in the end we all learn differently, so long as you’ve gotten this understood now, you can move onto your next challenges.
Most of the help you recieve on the forum from experienced users would be proper advice to follow and attempt. And if after attempting it doesn’t work, coming back with more information will help other forum members provide other potential solutions or point out where you may have gone wrong in implementing the original suggestion.
I’m certainly not interested in getting into a back and forth about it and your point at face value is valid and fair, but many of your responses in this post were simply inaccurate. Your understanding of how custom workflows trigger, specifically in relation to immediate searches for DB items after a previous custom event created said DB item is again not accurate. I also clearly stated the things I had tried prior to posting, including the suggestions you made. I had no interest in going down a path that I knew was both not going to work fully and also would become extremely complicated to manage in the future. It appeared to me that you were unable to get past the missing conditional in my screenshot which was both erroneous, and not in any way part of the problem.
In relation to your quoted post regarding the custom trigger, that was not and is not the solution. With that said, I know that you did not fully understand what I was trying/needing to accomplish because I did not go into extreme detail as you requested, so that is certainly not on you.
Again, a fair response, but I’d argue the amount of bad information on this forum (of which there is tons) is way more harmful.
No worries, just trying to be helpful to allow you to be a bit more open minded to the suggestions you recieve from experienced users. I believed when you replied to me and it showed up in my alerts that you wanted my attention on your post, especially as you had linked to it in your other thread was in my alerts as well, and so the reason for my reply to it.
Good luck on the continued development.
But just to help your further for the future. The terminology used for
is referring to the same thing when referenced as
or
and for your continued store of knowledge the below statement is true
as you have come to find out
Always a good idea to keep the bits of wisdom you pick up stored for future reference.