I am creating an inventory app. There are "Property Managers" at specific locations who need to see only the data for their location. I am also limiting them to see certain columns based on their user role. That was pretty easy.
Where I'm having trouble is writing the security filter expression that looks in the "User Manager" table and finds the Role that is "Property Manager" then finds the "Location" that displays only the matching records from the "Inventory table" at that "Location". "Admin" users should be able to see all records. Can you please help? I've searched Google and Youtube. I am new to Appsheet and coding.
@DGillcpa wrote:
Where I'm having trouble is writing the security filter expression that looks in the "User Manager" table and finds the Role that is "Property Manager" then finds the "Location" that displays only the matching records from the "Inventory table" at that "Location". "Admin" users should be able to see all records. Can you please help? I've searched Google and Youtube. I am new to Appsheet and coding.
Hi @DGillcpa
You may want to use this expression in the security filter of the table "Inventory table":
OR(
USERROLE()="Admin",
AND(
LOOKUP(USEREMAIL(),"User Manager","email","role")="Property Manager",
LOOKUP(USEREMAIL(),"User Manager","email","Location")="Location"
)
)
For reference:
Limit users to their own data - AppSheet Help
@DGillcpa wrote:
it still shows records for every
location in the preview
In the preview you are always considered with USERROLE="Admin" no matter the setting you use, hence this behavior. I admit this is quite confusing.
Can you give it a try out of the preview pane, and with another account than the app owner's account?
User | Count |
---|---|
43 | |
26 | |
23 | |
14 | |
12 |