I have a backend API workflow that should change a status field based on a condition.
If the condition is true, the (data) field “status” should be changed to “option A”, and if the condition is false then the API should respond to its caller and change the “status” to “option B”.
Note that data actions run asynchronously.
My options the way I see it are:
- Test the condition 10 times (for every action in the workflow). The condition is a little complex so that’s not very efficient.
- Test the condition twice and use custom workflows for each result. But then how would I conveniently respond to the API call? Maybe the custom workflow can by itself be another API workflow but I don’t know how do compare the efficiency to option 1.
- Force an order with delays. I don’t have elements to change in the backend and the delay is ignored for data actions. So I think this path is impossible.
- Force an order with “result of step #”. To have a result for a step I need to reference (i.e., change) the thing. If I reference it unconditionally then the subsequent actions aren’t orders, even if they change things or are conditioned themselves. Otherwise if the reference step is conditioned, then the condition result might be false and in that case subsequent steps cannot use its result because it’s empty. Maybe there is a complex way to get a conditioned value in some other field while always returning the same result for the step. But I don’t know how to do that or if it is computationally more efficient than option 1.
I wonder what is the best way for this pretty generic problem.