Permissions - field access based on the value of field in a record

  • 1
  • 1
  • Question
  • Updated 7 months ago
  • Answered
  • (Edited)
I have activities form in my app, one of the field is company id in that form. A company will have many users. I want to hide specific fields in a form based on the logged in user belongs to the company or not. How i could achieve this?
Photo of Avinash Hiremath

Avinash Hiremath

  • 112 Points 100 badge 2x thumb

Posted 7 months ago

  • 1
  • 1
Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
Make sure the company users are all in a user field. I would use a List-User field where you can add up to 20 users. Add that field to your form rule and state When "List-User" field includes "Current User", show fields.
Photo of Avinash Hiremath

Avinash Hiremath

  • 112 Points 100 badge 2x thumb
Thank you for your reply. But i do have more than 20 users belongs to a company, any alternative solution?
Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
You need to find a way to group these individuals. Can you group company employees within a specific role and then use the role in a rule? Or create more than List-User field and have a rule stating if they exist in this field or the other field, then show fields. 
Photo of Charlie

Charlie

  • 294 Points 250 badge 2x thumb
Hi Gil,

This is certainly achievable (if I'm understanding correctly) but the setup is a bit tricky...especially if you have a lot of tables and/or a deep hierarchy. I mocked up a basic example below. Keep in mind this is security by obscurity, since form rules are NOT database permissions; and QB doesn't currently support field level (conditional) user permissions.

The basic idea is to write a formula in your table that contains users; that resolves to the value of 1 if it's the current user's record and 0 if its not. THEN you can summarize that value up to your companies table, and pass it over to any child tables as a lookup. THEN you can use this field to control hide/show form rules.

I hope that makes sense!

Charlie

Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
Hi Charlie,

Although this wasn't my topic, I like your idea. I was wondering how to use a User table to make this work. 

Avinash, Charlie's idea would work for you.
Photo of Charlie

Charlie

  • 294 Points 250 badge 2x thumb
ahhhhh my bad...yes my comment was directed at Avinash!

Thanks Gil :)
Photo of Avinash Hiremath

Avinash Hiremath

  • 112 Points 100 badge 2x thumb
Hi Charlie,

Thank you! it worked.