Is it possible to restart a workflow or loop a workflow (or custom event) based on conditions? My goal is to generate a 6-digit unique ID on account creation, and don’t want duplicates. Thanks.
Sounds like you have two different questions? Yes you can have a workflow schedule itself making a loop. But you don’t want it for your unique ID purpose, that would just be a workflow you run when the user signs up.
My issue is I don’t have a paid plan, so am unable to use or schedule API workflows. But I’m just trying to figure out a way to loop or repeat or restart a workflow based on a set condition.
Without backend workflows you would have to keep the page open for anything to happen, but you could create a loop by making two custom events where #1 does the thing you want, then schedules #2 a second later, then schedules #1 again.
Just tried that, didn’t work. I think my only option would be to have a fixed amount of safety workflows that confirm (maybe 3 or 4) and then if somehow it generates an already used string 4-5 different times, it will just create an alert to let an admin know to edit it manually. I appreciate the input.
Make sure when scheduling the custom events you schedule them for Current date/time +seconds (1)
. I noticed when they are just triggered or scheduled with 0 seconds it doesn’t loop correctly.
I remember seeing something on the forum about someone generating unique coupon codes maybe search around. Also you can use slugs to guarantee no duplicates
Tried that with the custom event, didn’t work… thanks for all your help and suggestions.
What do you men it didn’t work?..
You’re obviously doing something wrong if it’s not working… but without knowing what you’re doing it’s a bit hard for anyone to help…
So feel free to share some screenshots of what you’ve actually done, and I’m sure someone will be able to point out where you’re going wrong…
It physically did not work… the workflow didn’t trigger. I monitored step-by-step in the debugger and when it got to the point where the action that schedules the event occurred, the workflow ended. Nothing happened.
And anyway, if a recursive workflow doesn’t work when you trigger a custom event, I don’t think it will work by scheduling one either.
As I said, you’re obviously doing something wrong… but if you don’t want to share what you’re doing then fair enough…
Maybe stick with your other plan…