Hi,
i’m wondering if it is possible to set a conditional parameter in API worflow such it could be written in javascript : (condition to test) ? (value if true) : (value if false).
I sometimes would like to avoid having multiple workflows to trigger depending on “only when” conditions.
ex: param = (object field value is empty) ? Result of step1 : Result of step2
Thank you
The closest thing to a ternary operator in Bubble is the ‘formatted as text’ operator on a conditional expressions (which actually is a ternary operator… it’s just that it can only output a text value).
So, it can be used for this, although it’s a bit more fiddly than it should be.
one way you can do it (assuming that the results of step 1 and step 2 are both a ‘Thing’ of the same datatype), is to set your parameter value to Search for a thing, by Uniqiue ID, and then use a ternary operator (in Bubble, a conditional expression, formatted as text) to define the Unique ID to search for.
e.g.
Search for Thing where Unique ID is (object field value is empty: formatted as text [yes: result of step 1’s unique ID | No: result of step 2’s Unique ID).
Depending on your workflow, and exactly what you’re doing, you may also be able to use a Custom Event for this. You can move step 1 and step 2 into a Custom event, which outputs the result of either one depending on some condition, and then just use the output of that custom event as the value for your parameter in the API workflow.
Thank you very much @adamhholmes , your response are always very precise and appreciated.
I just found out the 2nd option with custom event returning result and that’s perfect to answer my need.
1 Like