How to reference to another Data Type

Hi

I have two Data Types

They’re connected by User id.

When setting up a workflow I see only the fields from the User table.
2023-12-17 20_30_02-Subby _ Bubble Editor

How can I find and refer to the fields in User Account tables in the workflow?

Thanks
/Marat

You’re trying to change the Current User (which is a User), so you can only modify fields on the User datatype… and you obviously haven’t got a User Account field on the User datatype.

If you’re intending to modify the User Account, rather than the User, you’ll need to change Thing To Change to a search for User Accounts, where the User is the Current User (although it might be better to have a User Account field on the User)

Why do I need to have User Account field on User datatype if I already have a relation between User and User Account through User_id and UserAccount_id - (meaning I have Username field in User Account referncing to Username in User table)?
Am I missing something?

I followed instructions on this page to set up my data types relations

We’ll you don’t need to…

But it will be simpler, faster, and more WU efficient that way, as you won’t need to do a search for it.

I can’t see anything on that page that would suggest doing things the way you have… (not that it’s wrong… it’s just not optimal).

That said, what exactly is the purpose of using two datatypes here? given that the User Account datatype has only 2 custom fields (and one of those is just a reference to the User)?

User table is getting stuffed with too many attributes/fields, so i created a second table which will hold some additioanl info for user account

Well, In Bubble, we would create a field Usernam in the “User Account” table with the data type “User”, which would represent a reference to a user record (Username) in the “User” table.

I can’t find that on that page…

But if you’re referring to this:

They are talking about a Post datatype, which is very different from a User Account datatype (a User may have many Posts, but only one User Account).

For something like a Post datatype, having a User field is definitely the most optimal way to do things (it’s a one-to-many relationship)

But for a one-to-one relationship, like a User Account datatype, being able to refer directly to the User Account from the User is more efficient (and simpler).

1 Like

OK, maybe I need to elaborate more on what I’m trying to achieve here.

User Account has a field called Occuoation and it needs to be updated with the relevant value when user selects a checkbox (predefined list through option set).

Defenitely User to User Account is a one-to-one connection.
Now I have added User Account field in User table.

I also created a “Make changes to thing” workflow on the submit button and want to figure out how to submit/store the value of the selected checkbox(s) into the Occupation field of User Account table.
2023-12-18 12_18_06-Subby _ Bubble Editor

Thing to change: Current User’s User Account

field to change: Occupation = checkbox’s value

1 Like

The check box is not a Bubble standard checkbox. I have used icon+text combination inside a RepeatingGroup. The Repeating Group is populated from a Option Set list. So not sure how to pick up its value… :frowning:

However you’re storing/defining the selected value from the checkbox, just use that as the value to store in the database.

I did it, but get this error, not sure whu cuz I’ve slected the value not the list

Well the error is telling you exactly what’s wrong…

(i.e. the value needs to a a single thing, but you’re trying to set it as a list of things).

So, either your database structure is set up wrong for what you need, or your Custom state is a list (which it is), when it shouldn’t be.

I don’t know which of those it is, as I don’t know your intention… but the type of data (including whether it’s a single thing or a list needs to be the same).