Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How can we access the userId or email id associated with the currently logged in user!

Issue

I need to record the email id of the person taking action on the tickets in our portal, as all tickets are visible to all users on the dashboard. I'm wondering how to achieve this and if the information is stored in an environment variable or something similar. I was given the idea to use the "user" object, which can be bound to {{appsmith.user.email}} to display the logged-in user's email address in a text widget. This was very helpful, and I appreciate the quick response! Can you share a reference link to their documentation on the Appsmith Context Object for future reference?

Resolution

The solution is to use the "user" object in Appsmith to get the email address of the logged-in user and then store it as a variable to be included in the payload sent to the endpoint when the submit button is clicked.

To display the email address in a text widget, the following code can be used:
{{appsmith.user.email}}

This code pulls the email address value from the "user" object and displays it in the text widget. Additionally, the email address can be stored as a variable using JavaScript or any other programming language supported by Appsmith.

The documentation on the Appsmith Context Object provides more information on how to access and use the "user" object, as well as other objects in the Appsmith environment.