Get Current User Details in Lightning Web Components
Today in this post we will be discussing how to get current user details using lightning web component(LWC)
To access the current user Id, import @salesforce/user/Id in a component’s JavaScript class. Note that @salesforce/user/ cannot be imported by itself; you must indicate the property that you want to import. For the User standard object, only the Id field is available.
To access other user fields like Name, email import
'@salesforce/schema/User.Name';
'@salesforce/schema/User.Email'
Please follow the below code to fetch current user detail.
1. User_Html file.
2. User_Javascript file.
3. User_Meta_Xml file
Like our post & bookmark this blog for your future learning.
Any suggestions and improvements are most welcome, please comment your suggestions and improvement in the comment box.
Happy Coding Sharing Is caring. 😀😀😀
Post a Comment