So I made a real estate app where you can rent or buy properties.
Inside each property, besides seeing all its details, I want to display who’s the owner and have the ability to click on it and see some of his information.
I’ve tried using a Collection linked to the users tab but it shows the profile of the signed-in user (I guess this is because the Users tab is user-specific, right?), so I tried linking the properties tab and filtering it to show just the properties the owner has, but it’s not working.
In your Properties table, create a column that you can use for the Property Owner. Ideally this should be either the Owners email or their UserID (RowID) from your Users table. Then create a single relation column that matches Properties->Owner to Users->OwnerID (or email). Then you can add one or more lookup columns that fetch owner details via that single relation, and you will be able to use those values to display on your Property details screen.
The second screenshot is of the Properties’ Table, where I have the Owner’s name (Column “Anunciante”), a relation between the owner’s name and the user’s name, and then the lookups of some of the user’s information.
Okay, so here is where it gets a little bit complicated, so please bear with me and I’ll try and explain as best I can.
What you will need to do is create a separate “Public Users” table that contains only the information that you want to make public. And because you’re using Glide Tables only, the arrayformula method mentioned in the docs isn’t available.
Probably the simplest method with Glide tables is to create a simple onboarding flow, and at the end of the flow have your Users click a button to continue. And you need an action attached to that button that does an Add Row action, creating a new row in your Public Users table with that users public information. When creating that row, you should be able to use User Profile column values to populate all columns.
And then with the relation that you created earlier, instead of matching a value in your User Profiles table, you would match a value in your Public Users table.
The other thing that you’ll need to take care of is keeping your Public Users table in sync with your Users table. For example, if one of your users changes their profile image, you’ll want that to be reflected in your Public Users table.
The way to do this is to create a single relation column that matches Users->UserID to Public Users->UserID. And then anywhere in your App where you allow a user to edit their profile, you’ll need an action that does a Set Column Value via that relation, setting the new values in the Public Users table.
Darren, thank you so much for everything you’ve done to help me!
I think I found a solution based on what you recommended.
This is what I did.
My page is public and has optional sign-in.
When a user wants to publish a property, they have to sign in and update their profile, so I have a sign in button and then an update profile button. The latter is set up that when they submit their information, their information is updated in the users tab (which is private -it has Row owners) and it also adds a row to a Public Users table with the information that I want to have open for other users to see.
By doing this, I managed to display a collection with the user’s public information for each property advertised.
I believe this is exactly what I needed and I’ve tested the app and it’s working… what do you think? Am I missing anything?
The only other thing you need to deal with is keeping the two tables in sync…
Oh, and you’ll also need to make sure that what you have doesn’t result in duplicate rows in your Public Users table. So you should have some logic with your Add Row action that causes it to only add a new row if one doesn’t already exist.
What I did was that when the user updates his profile for the first time, it adds a row to the Public Users tab, but if they update their profile once more afterwards, it only updates the Users Tab (the one with the private info).