Apex: Id currentUserId = UserInfo.getUserId(); VisualForce: <p>Current User Id: {!$User.Id}</p> <p>Current User Email: {!$User.Email}</p> AuraComponent: let currentUserId = $A.get("$SObjectType.CurrentUser.Id"); LWC: import CURRENT_USER_ID from '@salesforce/user/Id'; import CURRENT_USER_NAME from '@salesforce/schema/User.Name'; import CURRENT_USER_EMAIL from '@salesforce/schema/User.Email';
Everything about Salesforce