Discussions

Expand all | Collapse all

Capture Current User's role in formula text field?

  • 1.  Capture Current User's role in formula text field?

    Posted 08-04-2015 17:47

    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,

    Chris



  • 2.  RE: Capture Current User's role in formula text field?

    Posted 08-05-2015 15:20
    There is a variable within the HTML of the page, so if you can use JavaScript you can get the role ID and then go from there.

    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


  • 3.  RE: Capture Current User's role in formula text field?

    Posted 08-05-2015 15:52
    There are no formula function that will return the user's role. Moreover, a user can be in multiple roles at once so any potential function would have to return all roles.

    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:

    http://pastie.org/10331624


    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.

    Pastie Database
    https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=439


    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.


  • 4.  RE: Capture Current User's role in formula text field?

    Posted 12-21-2018 17:49
    Is there a way to utilize information retrieved from an API in a formula field?


  • 5.  RE: Capture Current User's role in formula text field?

    Posted 04-08-2019 22:07
    Nick, did you ever figure this out?


  • 6.  RE: Capture Current User's role in formula text field?

    Posted 04-09-2019 12:40
    You can use this method in an IOL script like Dan describes above, but you cannot permanently place the value into a field via this technique. Because of this, it cannot be used in automations, notifications, or formula fields (at least as far as I understand it).


  • 7.  RE: Capture Current User's role in formula text field?

    Posted 09-15-2015 20:41
    Can you 'show' me how to apply it?