How to either create a Thing or use an existing Thing in a workflow?

A user enters unique information describing a Thing in a form and I need to either create this new Thing or find the matching Thing in the database and then use either the new Thing or the matched Thing for additional steps in a workflow.

In traditional programming I’d assign a variable in an if-else statement and then use that variable in the later steps of the workflow but I’m not sure how to achieve the same result in a Bubble workflow?

You can do the same IF ELSE in bubble using two workflows.

Workflow 1 checks to see if there is that unique thing in database:count is not Zero. If so, execute workflow.

Workflow 2 does the opposite check, with a different workflow.

1 Like

Ahh I see! And then the final workflow just has a Thing passed into so that both other workflows can call it?

Perhaps it is worth clarify that what I’m really trying to avoid here is code duplication. I have the same workflow that I want run on a Thing I just couldn’t quite work out how to pass the Thing I wanted into that workflow.

It would be helpful if Bubble didn’t try to be so clever and ignore all the cool shit that’s built into JavaScript. In JavaScript, “boolean” operators don’t just return a boolean value – THEY RETURN THE VALUE THAT MADE THE OPERATOR COMPLETE.

So, in our case, all you want to do is get matched_thing OR create some new thing. In JavaScript we would just say:

matched_thing || function that creates some new thing

Love that no code, am I rite? :wink:

1 Like