User role as variable

When user logon to retool the user will fist select a role user has access to from a dropdown list.

  • discipline 1 - value 1
  • discipline 2 - value 2
  • admin - value 99
  • etc

Is it posible to link selection value to user so user do not need to select this each time user refrechhing page (F5) or go to other App’s.
User needs to go to profile to change this.

If posible how do i set it an how can i get the value?

Im using it in task list as diffrent roles has diffrent tasks and access.

hi @Thore going to try similar task for myself soon. does User attributes | Retool Docs work to set values?

Hi @trz-justin-dev
This did not work as I'm using free trail self hosing for now.

I have also tested The localStorage object | Retool Docs

but then i get SetValue is not defind.

If there are anybody that can share example code I will much appreciate your help.

1 Like

Hi @Thore!

You can create a JavaScript query to store the selected role in the localStorage. That could look something like this:

Later you can the value from the localStorage like this:

Hope this helps!

2 Likes

Hi @avr

Thanks you this worked.

I'm now using the variable in my SQL like {{localStorage.values.MyRoleID}}

-Thore

2 Likes