Hello QB Community,
Has anyone devised a way to capture the current user's role in a formula field?
I currently use form rules to discern a user's role, but I have to create a form rule for every possible role, and this method also requires maintenance.
Nice to have a dynamic way to capture the user's role as it appears in the QB list of roles for a particular app, then do a thing after it has been captured.
Thanks for any help,
It is stored in the page as gReqUserRoleID. You can get the roleID's from the role page and go from there. I would just grab the value, do a case statement, then return what you need in the formula field
However you can obtain this information using script and the API method API_GetUserRole. Here is the XML Response for me calling API_GetUserRole on an application where I am in both the Administrator role and Basic Access with Sharing role:
Since there is an API method that returns this information you should use it an not dip into the pool of Global Variables where QuickBase for its own purposes has some of the same information in the source of its pages. But on the other hand there is no harm in poking around and understanding what global variables are within QuickBase pages. See the attached screenshot of the developer console where three global variables that contains role related information and logged.
R>I would just grab the value, do a case statement ...
If there was no API method that returned the roles (but there is), I would use underscore and gReqUserRoleIIDs (plural) the object gRofo to return all the roles the current user is a member of.