Skip to main content
Question

Formula to get the roles of everyone in people table

  • January 10, 2024
  • 0 replies
  • 568 views

We need to base our record pickers in our People table on their roles in the Users table. How do we make a field in the People table that shows their role?



------------------------------
Krissy Mayes
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+9
  • Registered
  • January 11, 2024

Unfortunately there isn't a way to apply a formula against a field/record in a table. You can do UserRoles() but that will only return the role of the current user. 

If you need actual role information - you will have to invoke API_UserRoles via a pipeline or some other method of integration and match up the user role(s) with the records in your table. 



------------------------------
Chayce Duncan
------------------------------

Forum|alt.badge.img+5


For jinja & JSON novices like me, here's what I finally figured out in order to deal with the error message that is thrown when a user has no role in the app and you're trying to populate a field with the role name property. I added a condition that checks to see if a role is returned, and then if so, populated with the role name property, and if not, populated with None. It took me forever to figure out the right syntax to get the expression to actually evaluate properly (I had to use the tojson filter to actually get a value to compare against), so hopefully this helps someone else as well.

Expression evaluates to TRUE:
{{quickbase_make_request_1.json.qdbapi.user.roles|tojson!='null'}}

If TRUE, then populates the Role field with {{quickbase_make_request_1.json.qdbapi.user.roles.role['name']}}

If FALSE then populates the Role field with 'None'