# Relation in same table

**URL:** https://community.glideapps.com/t/relation-in-same-table/61665
**Category:** Ask for Help
**Created:** [May 12, 2023, 3:03am UTC](https://community.glideapps.com/t/relation-in-same-table/61665 "2023-05-12T03:03:34Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 3:03am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/1 "2023-05-12T03:03:34Z")

</div>

I have a User table wherein Roles are Client, Representative, Admin.  
I want to assign a Representative to the Client so I created a Relation column which is linked to same table. I have also added some lookup columns for name and photo.

However, while adding the details in the app, it does not show anything while the details are visible in the table. What can be the reason of not showing the details? @Darren_Murphy @ThinhDinh

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 3:17am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/2 "2023-05-12T03:17:57Z")

</div>

Screenshot of the table, please.

PS. You don’t need to tag me in posts. You can assume that I read all posts, and if have something to contribute, I will.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 3:24am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/3 "2023-05-12T03:24:12Z")

</div>

Hi Darren, thank you for reply.

Here is the screenshot.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/c/1c3e6e7bb58db8b310ec70784640f1d20d2f479b.png)

> [@Darren\_Murphy](#):
>
> PS. You don’t need to tag me in posts. You can assume that I read all posts, and if have something to contribute, I will.

Sure, sorry if that was bothering.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 3:34am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/4 "2023-05-12T03:34:24Z")

</div>

The user you’re viewing as only has access to the first row in the table. You can tell that, because the other rows are dimmed out. So there is something wrong with your row owners/roles configuration.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 4:15am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/5 "2023-05-12T04:15:17Z")

</div>

Yes, that was an intention. That’s the reason I am using relation to bring second row to first raw. If you see last four columns, which are visible in first row. I just want to show those details in one of the screen. But its not happening.

If that is how it works, how do I achieve it?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 4:18am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/6 "2023-05-12T04:18:53Z")

</div>

Your relation won’t work on a user device, because there will only be one row. Rows 2 & 3 will not exist. If you want to use data from other rows, then the signed in user needs access to those rows.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 4:24am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/7 "2023-05-12T04:24:27Z")

</div>

Thank you. that makes sense. What do you think is the best way to achieve this? If you can guide me, that will be helpful.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 4:28am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/8 "2023-05-12T04:28:58Z")

</div>

Well, lets go back to your original question:

> [@Pratik\_Shah](#):
>
> I want to assign a Representative to the Client

I would have an email column to hold the representative email address, and then make that column a row owner. No relations or lookups required.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 4:32am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/9 "2023-05-12T04:32:35Z")

</div>

Thank you. However, in terms of flow, when a new User is added by Admin using Form, he will select which Rep is to be assigned. Now, there is a chance that one Rep can be assigned against more than one Client. How to handle that? So, more than one User (client) will need access to another same row.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 4:43am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/10 "2023-05-12T04:43:55Z")

</div>

Are Client users and Representative users all in the same table?  
If they are, then that’s fine. The same Representative email address can appear against multiple clients.

It would only be a problem if you need to assign multiple representatives to the same client. If you need that, then you would either need multiple representative/owner columns, or (better) make use of roles as row owners.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 4:54am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/11 "2023-05-12T04:54:21Z")

</div>

> [@Darren\_Murphy](#):
>
> If they are, then that’s fine. The same Representative email address can appear against multiple clients.

I guess its other way round. If I want a Client User to access the row of Representative User, I need to mention email id of Client User in Rep User’s row. Is that correct? Then how do I do that?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 5:34am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/12 "2023-05-12T05:34:18Z")

</div>

I’m a little confused. Which of the below best describes your use case:

a) One Client has one Rep  
b) One Client can have one or more Reps  
c) One Rep can have one or more Clients

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 7:48am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/13 "2023-05-12T07:48:06Z")

</div>

> [@Darren\_Murphy](#):
>
> c) One Rep can have one or more Clients

This is correct one.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 7:55am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/14 "2023-05-12T07:55:10Z")

</div>

Okay, so in that case you just need a secondary row owner column in your Users table, and add the Rep email address in that column, for each of their clients.

Presumably the Rep should also have access to their associated clients data?  
If that’s the case, you would also need to do the same as above in any table where you are applying row owners.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 8:02am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/15 "2023-05-12T08:02:22Z")

</div>

I am sorry but I am still confused.

What I want is, Client should access the details of his Representative (who is also User). So in that case, I need to add client’s email id in its Rep’s row. Am I correct?

So if Client 1, Client 2 and Client 3’s Rep is same, I need to add total three email ids in Rep’s row and make it row owner so that all those clients can access Rep’s details.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 8:26am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/16 "2023-05-12T08:26:58Z")

</div>

Yes, that’s correct.

If you could have many clients associated with the same Rep, then it may be better to use the RepID (RowID) as a Role. Then you could assign that as a Role to each associated client and make the RowID an Row Owner Column.

For example, take a look at the below screen shot:

 ![CleanShot 2023-05-12 at 16.23.52@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/0/4077bd1b26130066ee9bc9c3797219deef36ffa7.jpeg)

- Marie is a Rep, and she has two clients (Tamsin & Alan)
- Email is a Row Owner, and RowID is a Row Owner
- I am viewing as Tamsin, and I have access to two rows:  
– My own row, because my email address matches the value in the email column  
– And Marie’s row, because my Role matches Marie’s RowID

If I switch that to viewing as Alan, then I see my own row and Marie’s row, but not Tamsin’s:

 ![CleanShot 2023-05-12 at 16.27.36@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/2/c2fae34afa8bc8ec1e3bce3a2b9d019fc74a41b9.jpeg)

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 8:49am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/17 "2023-05-12T08:49:47Z")

</div>

That is a good idea.  
I have already set up Role as Client, Representative and Admin. If I change the Roles of Client, how do I configure the actual role for the entire App?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [May 12, 2023, 8:56am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/18 "2023-05-12T08:56:25Z")

</div>

You don’t need to change anything in your User Profiles configuration, but you may need the following changes in your Users table:

- instead of using the word Client as a Role name, use the RowID of the associated Rep, as shown in my example.
- for your Admins (assuming that they should see all users), then you will need one more column with Row Owners applied, and put the word Admin in every row.

---

<div class="post-metadata">

### Author: ![Pratik\_Shah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pratik_shah/32/12416_2.png) [@Pratik\_Shah](https://community.glideapps.com/u/Pratik_Shah)
#### Post date: [May 12, 2023, 9:19am UTC](https://community.glideapps.com/t/relation-in-same-table/61665/19 "2023-05-12T09:19:28Z")

</div>

Thank you for the idea and answering my questions. I will try this method. Thank you for continuous support and help, as always.
