Access all Users in an account

Can you access all of your instance user details from within an app. For example I want a dropdown of users within my Retool instance to use values within an app, tag employees to records, actions, notes, etc. However, they may have not logged into Retool yet.

You could use currentUser and insert into a locally controlled User table on page load but would be nice to tap into the Retool User object.

1 Like

Hey @teamrappid — you can do this in the on-prem version of Retool in a roundabout way. When you deploy Retool on-prem, you control access to the database where users are stored. You can add this database as a resource in Retool and query it inside Retool apps to get the full list of users.

We don’t have great documentation on this, but if you want more information let me know and we can help!

2 Likes

Hello @alex can you sharedocumentation in how to access this database? I have Retool on-prem.

1 Like

Hi @Gabicus! Welcome to the community and thanks for posting.

The credentials to the database are stored as environment variables (e.g. in the docker.env file). You can grab those creds and then use them to add a Postgres database resource in Retool. Then you can query this database from Retool! :exploding_head:

1 Like

Hi @Gabicus, I wanted to add to Alex's response here. Please kindly note that this solution should be implemented with significant caution in production environments; having the backing database available as a resource may pose issues if not carefully managed (data being inadvertently updated or deleted, the database being over-utilized, etc.). As such, if you choose this solution, here are a few considerations/recommendations:

  • Add the database resource using a read-only database user credentials.
  • Ensure that your database has the necessary back-up and restore functionality.
  • Ensure that the database resource permissions are tightly scoped within your Retool organization.
1 Like

Just a tiny note on this, it would be really nice to see a user lookup to get a username from a userid. At the moment I'm saving the current_user.firstName into my db but obviously would prefer to store the ID and run a lookup when displaying historic records from that user. I'm not an on-prem client.

3 Likes

+1 here on this