Hi Bubblers,
The action trigger custom event when data changes
seems to behave inconsistently.
By inconsistently, I mean it triggers sometimes and sometimes it doesn’t.
Our workflow is structured like this:
- Make changes to a thing
- Trigger custom event when Step 1’s field changes
For context, this is a marketplace app wherein if user adds a product to their cart and that product is already in their cart, it merges the order with the order that is already in the cart - updating the cart order’s quantity field and other fields e.g. subtotal, etc.
Here’s a more detailed explanation of the workflow:
- We search for orders with the same details (same product and variation)
- If search count is 1, we search for that order and make changes to that thing
- We update the order’s
quantity
field - In the backend, we have a DB trigger to update the order’s
subtotal
andprofit
if order’s now’squantity
is not order before’squantity
- Circling back to the frontend workflow, we have “trigger custom event when order’s subtotal changes” action after step 3.
The issue here is that step 5 “trigger custom event when data changes” behaves inconsistently. There are times where it works fine and sometimes where it doesn’t trigger.
The actions in the custom event are simply frontend actions such as hiding loaders, showing confirmations, and resetting states.
Initially, I thought the cause was that the workflows were triggered even if the search wasn’t finished yet — leaving the order
parameter empty
Turns out that this isn’t the case since the action that changes the order’s field are being performed and the fields are being updated accordingly.
Another reason I thought about was that the DB trigger that changes the order’s subtotal
was already performed before the custom event could even “watch” the order data and by the time that it “watches” the thing, the change has already occurred.
With that in mind, I have tried these workarounds:
- Placing the “trigger when order’s subtotal changes” action before the action wherein we update the quantity.
- Using “result of step 1” (order) to ensure that the workflows are running synchronously.
- Changing the “field to watch” to order’s modified date and profit (these fields are being updated in the same workflow where the subtotal is being updated)
But the issue still persists. The “Trigger custom event when data changes” action still only triggers randomly.
This isn’t due to privacy issues as well since we have already gone through them.
I also tried to manually change the order’s subtotal which SHOULD trigger the custom event but still the same, it triggers sometimes and sometimes it doesn’t.
It would make sense if the behavior was consistent i.e. the custom event won’t trigger at all since we could deduce that there really is something wrong with the workflow but that’s not the case
I’m pretty sure I’m missing out on something here. I would really appreciate it if you guys could guide me.