I am building a table where I store the {{ current_user.email }}
.
Is there a way I can retrieve the user's full name from the stored email or do I need to store the full name as well?
I am building a table where I store the {{ current_user.email }}
.
Is there a way I can retrieve the user's full name from the stored email or do I need to store the full name as well?
Hi Shawn,
you can get the user first and last name with {{ current_user.firstName }} {{ current_user.lastName }}
Hi @Almopt,
That is not quite what I am looking for. This is for an inventory system where multiple users will enter data. The table will have a user column with their email. eg
bob@abc.com
sue@abc.com
john@abc.com
In this case I would like to lookup the user names, not the current user.
Could you describe your use case with some prints please.
But for what I understood if you want to get the user names who inserted data, what you should do is when the user insert data you save user's email, first name and last name in you database. Then their names will come in the query you're using to display the data in the database.
Yes, I know I can store the first and last name as you suggested. I am wondering if in Retool I can pull other user data from an email.
I believe the answer is you can only do this if you have a table in your app with a list of users to lookup; in this case email and full name.
I was hoping there would be some sort of way to lookup users who are part of a group but I only see the The Current User object.
Yes the only way for what I know is storing the users details in the database. Retool for now doesn't have any way to fetch all the users details internally.
Hey @Shawn_Optipath! Thanks for reaching out. The objectively best solution for this particular problem is to use the Retool API for querying user information, but the majority of its endpoints - including most of those related to users - are scoped to the Enterprise plan.
The best workaround that I've seen is what you've already proposed - pulling the requisite information from current_user
and storing it alongside whatever other data you're persisting. At scale, this option is probably even preferred as it bypasses the need for additional database queries.
I hope that helps!
Hey @Darren , thanks for chiming in. I think you are right in that the data would be more efficient within.
It was fairly straightforward to do this in the background, automatically adding new users as they log in (or load the page).
JS Code:
upsertUser.trigger({
onSuccess: () => {
console.log("User record inserted or updated successfully.");
},
onFailure: (error) => {
console.error("Error updating user record:", error);
}
});
upsertUser:
INSERT INTO app_users (retool_id, email, full_name)
VALUES ({{ current_user.id }}, {{ current_user.email }}, {{ current_user.fullName }})
ON CONFLICT (retool_id)
DO UPDATE
SET email = EXCLUDED.email,
full_name = EXCLUDED.full_name;