Forum Academy Marketplace Showcase Pricing Features

Create thing if not exists - no association with current user

Hello

I recently started developing a web application with Bubble. So far I love the simplicity.

My app is something similar to a shop, where users can book/order something.

Today I tried to build an account page where the user can modify his address and other data. Because I have quite complicated data to save, I made various data types that are linked/associated to the user. (for example “address” data type with street, place and so on)

So, I thought let’s make a nice user account page where the user can see and update his data in the same input fields. No problem with “Initial content” setting.

However, I ran into a problem when I tried to write/update the input field contents to the database by using workflows with “Make changes to a thing”. The problem is described in the help document as “one important detail”:

Create if the thing doesn’t exist
By default, this action doesn’t do anything if the thing you’re trying to change doesn’t already exist. You can change this behavior clicking on this box. In that case, the action will be equivalent to ‘Create a new thing’, and use the changes as initial values. One important detail: if the thing that you’re changing is, for instance, the Current User’s thing, if that that thing doesn’t exist, the thing will be created, but won’t be associated to the current user data type.

My question now:

How can I overcome this limitation? What kind of workflow can I use to create associated things and link them to the current user?

I don’t see a possibility to have a workflow element like “check if current user has associated things, if not create new associated thing”…

Can anyone follow? :slight_smile:

I think in this case you will create (or make changes to) the User’s Address. Then in a second workflow I would make sure to set that specific ‘Address’ attached to the User with the following:

Make Changes to Current User
Address = Result of Step 1 (the step with the Address)

Thanks @gf_wolfer

This helped me link together the associated fields. And by changing the workflow so that I first create new things (with “only when” conditional statements) instead of using “create if the thing doesn’t exist” on the change thing action I am able to solve all other problems.

Thanks again.

1 Like