I have created a field that is of type "user" and set to "current user". Need to look up user attributes stored in a separate table.

  • 0
  • 1
  • Question
  • Updated 5 years ago
  • Answered

I have created a field that is of type "user" and set to "current user". Now I also have a User table that specifies users (first name, last name) along with the department they belong to amongst other attributes. How would I look up the user: department field value after matching the current user to the user name fields in the User table?

Photo of Krishna

Krishna

  • 10 Points

Posted 5 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
no problem.

Just set the Key field of the User Table to be the Userid field. Then make a relationship down to your details table based on that field. It's a hugely powerful technique. Aside from just looking up user attributes, it can be used to control security access.

For example if you only want to allow a user to be able to see their own "department". Rather than have the terrible clutter and nightmare maintenance of 10 or 20 Roles per each department, you just maintain a table of users and limit them in a single Role to "their" department on their user table which is looked up down to any details tables.




ie a Role Permission where [department] = [My lookup department]
Photo of Krishna

Krishna

  • 10 Points
Thanks Mark. I have a user table setup the way you suggested. I also have a lookup to the user department from a couple of detail tables. Now I am challenged with specifying role permissions to view records in a specific detail table. I see that I can create a custom rule for the User Department (my lookup) field equal to or contains a specific value but I cant equate it to my lookup department. How would I do this?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
You will need to do the "calculation" in a formula field, not the Role Permission.

Make a formula checkbox field called perhaps [user is allowed to see] or [This is My department]

The formula would be
[Department] = [User lookup Department]

Then set the Custom Role permission where [Allowed to see] is checked.
Photo of Krishna

Krishna

  • 10 Points
To clarify: The [Department] data point in my detail table would be collected independent of the [User lookup Department]?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
I was assuming that your detail records already have a department on them and you are trying to limit the Role so users can only see their own departments.
Photo of Krishna

Krishna

  • 10 Points
Just checking: Is this the only way to do this? i.e with the detail record having a department on them. I was wondering if I could limit visibility based on the current user data point, since we can lookup the current users department from the user table.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,792 Points 50k badge 2x thumb
OK, so now i am confused about what the data looks like in your application.  Can you state in a clean sentence or two what you are trying to do in terms of security or even flagging records in some way.
Photo of Krishna

Krishna

  • 10 Points
Its going to take more than a sentence or two to explain my data model, So never mind.