Display data by user roles in RG

Hello, i have an RG that contains orders placed by agents. So far i only had the admins views of all the orders and it worked great, but having to switch to each agents account to view his own orders … this is where i hit a bump. im fairly new to bubble and still getting to grips with everything.

Capture.2PNG

Here are my screenshots, what steps should i take to show all orders when user is admin and show user„s orders when user is agent? Conditional formatting, custom state? i need your help

Hey @raulbrindusann :wave:

You can use one custom state in the page (List of Orders):

When the user is regular, filter the search based on the agent and set the custom state:

When the user is admin, you don’t filter by anything:

Then, the repeating group in your page will be just using this custom state as source:
image

If you want to see the full editor, here it is: Bubble Demos by Flusk | Bubble Editor

bdk_512x512 @Huseyin from Flusk | Discover the #1 Security and Monitoring Tool for Bubble

1 Like

Should my data type for agent be Users?

im getting this error when trying to set up agent as current user

This depends on your system. I set mine as user, so it depends on you. Technically, I assumed there is a connection between the current user and an agent. If not, you filter based on that.

If you are not sure, show us your data types a little bit, such as Commenzis and Agents etc so I can give it a look.

bdk_512x512 @Huseyin from Flusk | Discover the #1 Security and Monitoring Tool for Bubble

That was brilliant. Thank you sir !

1 Like

Be aware of storing lists in states, it can crash the page if too much data (like more than 1000 I think). Things can work great when building with little data, but you ll we be surprised to how bad things happen at scale.

My advice is to have a popup named VAR

In this popup, add a group GR VAR AGENT with datatype of the agent.

Don t set the default datasource. Add a condition on this group, if current user role is agent, set datasource to (the agent, maybe a user or other datatype).

In your RG, make your do a search with agent= GR VAR AGENT and check “ignore empty constrains”

This how I usually set my Rg filtering.

:heart: to my friends from @flusk

1 Like