Update two databses to update button state

Hi,

I’m fairly new to Bubble so I would need some help in updating two datasets at once.

The first dataset is called Upcoming Events and it has the following structure:

The second dataset is called Event Participants and it has the following structure:

What I’m trying to achieve is switching a frontend button state from Register to You’re Registered when a user hits the Register button.

I’m open to whatever suggestions you have.

Thanks in advance!

Yes, that’s exactly my thought. The only problem I’m having is that I don’t know how to update the Upcoming Events’ Event Participants automatically when a user hits register. Right now only the second dataset I showed above is updating.

Strike both of my previous responses… gonna start over here. :slight_smile:

Is there a reason the Event Participants field in the Upcoming Events data type isn’t a list of users?

No. That’s a good point. I’ll set it up like that.

What should I do next?

Cool… that field being a list of users should simplify things because then all you have to do when a user clicks the button to register is make changes to the current page’s or parent group’s event, and the change to make is to add the current user to the event’s Event Participants field. At that point, the button conditional I mentioned in my first response (which I deleted because I initially misunderstood your post) should work, and that condition is something like Current page's Upcoming Event's Event Participants contains Current User. When that condition is true, change the button text to You’re Registered and disable the button.

It should be noted that if an event can contain hundreds or thousands of users, you might be better off from a performance perspective of going with a separate data type that makes an associaton between an event and a user (which is essentially what you were doing before). With that data type in place, you would get rid of the list field on the Upcoming Events data type, and your button conditional would be a count of a search through the new data type for a thing created by the current user and associated with the current page’s or parent group’s event.

1 Like

@mikeloc I think for now your first solution is perfect. Thank you so much, it works exactly like I want it to work, I don’t expect to have more than a few hundred users any time soon.

Thanks a lot for all the help!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.