I asked a similar question at Retool Office Hours yesterday and the answer was currently no, unless you are Self-Hosted. They can query their user table directly to get this (ask elsewhere how to do this, I only know it is possible.)
One of us should add a feature request.
One of the other participants (sorry I did not catch who or I would give attribution) had the germ of an idea which I was able to grow into a workaround yesterday. When your user first logs into an app (maybe an onboarding app everyone signs into first) you run a js query.
- Have a user table which has their email (you control that at least) and a retool_id field.
- Query your users table by the current_user.id
- If you get no results, query your user table by email.
- If you get a result, update your user table with the retool_id
- If you get no result, the user is not in your user table yet or their email is wrong
Here is how I implemented that for my use case (external clients given access to their portal):
// Set 'Keep variable reference inside the query in sync' and 'Run on Page Load Option' options in Advanced Tab
let customer
// Get the customer by the logged in Retool User
customer = await qryCustomerByRetoolId.trigger()
if (customer.length > 0) {
await currentCustomer.setValue(customer[0])
return
}
// If we do not find that customer by a Retool ID then we look for them by email
customer = await qryCustomerByEmail.trigger()
if (customer.length > 0) {
// If we find them this way then set the Retool ID in that record.
// This will always happen when they first co to one of their pages and should not happen again.
await qrySetRetoolId.trigger({additionalScope: {customer_id: customer[0].id}})
// Remember the customer's record to use in the app
await currentCustomer.setValue(customer[0])
return
}
-- qryCustomerByRetoolId
select * from customer
where retool_id={{current_user.id}}
-- qryCustomerByEmail
select * from customer
where poc_email={{current_user.email}}
-- qrySetRetoolId
If I fail to get an email match I display this Alert component:
The account reps can manually add the retool_id.
Now when a client logs into their portal, I can link their retool_id to their customer_id and then get their records.