Forum Academy Marketplace Showcase Pricing Features

How do I link data between two Types of Things?

I’m trying to link data between two Types of Things.

My app is for a photographer. I have a “create new photo shoot” form. On that form I would like to give the photographer the ability to create a new client OR select from a list of existing clients.

So I created one Type of Thing called CLIENTS with these Text fields:

  • Client First Name (text)
  • Client Last Name (text)
  • Client Email (text)

I have another Type of Thing called SHOOTS with those same fields except I’ve set them to type Clients:

  • Client First Name (clients)
  • Client Last Name (clients)
  • Client Email (clients)

So how do I link those two types of things? My “create new photo shoot form” workflow will successfully add a new client to the CLIENTS table, but it will not add that same client to the SHOOTS table.

It’s important for this data to be linked so that if the photographer edits the name or email of a client, that information will update on all of the photo shoot records for that client.

This is my current workflow in photos.

Step 1: I create the new shoot - this works right now. This data all goes to the SHOOTS table.

Step 2: I create a new client - this works as well. This data is added to the CLIENTS table.

Step 3: I’m trying to say “change this shoot’s client’s name to the client name that was just added to the Clients table in step 2.” I can’t figure out how to do that.

Any help is greatly appreciated!!

It is much simpler than that :slight_smile:

On SHOOTS you create a single field called CLIENT (or whatever you like) of type CLIENT.

You then create CLIENT in your workflow. And then SHOOT and set SHOOT’S CLIENT to “Result of Step 1”.

This links the WHOLE client to the shoot not just a single field.

If you want to show the client’s first name for a shoot … it is just Shoot’s Client’s First Name. Simple.

3 Likes

Wow! That is simple!

Also, I learned from this that I need to pay more attention to the order of events in my workflow and how that affects my results.

Thanks so much for your help! You’re awesome :smiley:

1 Like

Hi, i would like to do a similar thing , the difference being that i would like to add a new item in a list.
to continue in the photo example, it would be the client type has a list of shoot, i create a new shoot and would like to add the shoot in the list of shoot of a client. do i need to link with the unique id ?
many thanks for your help


grafik

Arnaud

In your workflow above, step 3 should be “Make CHange to a Thing (Current User).” Then, inside that action, you specify the field you want to change is Community, and you want to Add result of step 2.

You don’t need to mess with unique ID’s or anything, Bubble does all that for you behind the scenes.

1 Like

It works :slight_smile: … and sounds logical … sorry for the silly question i should have done a pause and get more O2 to my brain before asking … many thanks
Arnaud

No worries at all! You only get smarter if you ask questions and make some mistakes. Glad it’s working for you.

then i ask a new question :slight_smile:
i would like to sort the displayed list ( repeating group of several things) by date


i do not know where to sort …

In the “Data Source” field, click the text that says “Event List.” Then, another little thing should appear after it that says, “More.” Click on that, then scroll down to find “sort by.” You can use that.

Hi @andrewgassen, I have been trying to do this as well for an event application.

I have already created two fields within data type:

  1. Data Type User: Data field’s such as
    a) ‘Saved Events’ (Type = list of events)
    b) ‘Events to be Attended’ (Type = list of events)
  2. Data Type Event: Data Field’s such as
    a) “Interested Users” (Type = list of users)
    b) “Attendees” (Type = list of users)

The question now is what should be the workflow:

  1. when a user will click on an Icon to ‘save the event/Interested event’
  2. when user will click a button to ‘attend the event’

Outcomes I need are"
(A) Register*( or Save)* an Event within User’s List of “Events to be attended (or Saved) ” and
(B) For Events “List of Attendees ( or Interested) ” to be updated in the database?

Should I create a new thing? to get the workflow to do this? Below are two screenshots in what I’m trying to do , a bit stuck here if its the right way to do it. Also not sure why

In the last screenshot (below), in the workflow, I’m trying to save/add events that the user is interested in / (or alternatively is attending). Why does it not accept the field current user’s events interested, what should I add further?

Could you please suggest? Thank you!

If I understand correctly, what you are wanting to do is this:
Add This Event to the Current User’s List of Events.

The thing you are actually changing is the Current User. I’m assuming you are showing Events in a repeating group, so the logic would look like:
On click of the Heart…
Make a change to the Current User…
Thing to change is Saved Events…
Add current cell’s Event.

Does this make sense?

Hi @andrewgassen, thank you for your reply.
What I am actually trying to do is as follows:

Database Side:

  1. Events as data type has a field ‘event attendees’ (field type for the field is list of users)
  2. Users as data type has a field ‘events to be attended’ (field type is list of events)

UI
I want to , with a click of a button, allow user to register for an event.

What should be the workflow to allow:

  1. A user to save an event
    (Field name events interested, as in the screenshot)
  2. A user to register for an event
  3. An event to receive the list of users, so an organizer can see who is joining.

Question:
a) So I tried the steps you explained above, I wonder if it’s right? I think it is right for changing a field. Screenshot attached

b) However how to implement change to a list of things? This is somehow still showing in red colour/issues in the workflow. Screenshot Attached

For changes to a thing -> Event -> Field to change Attendees -> Add ‘current user’ . Is it right?


I think I’m almost there. Could you please suggest? Thank you!