Get Current User Id Information in Lightning

Getting a Current User Info used to be a hurdle in lightning before Winter 18.

We have to call apex method to return system.UserInfo.getUserId() now we no longer have to do this method.

In the Lightning Controller, we just need to call the $A.get(“$SObjectType.CurrentUser.Id”) to get the information

var userId = $A.get("$SObjectType.CurrentUser.Id");
Console.log(userId);

This helps in reducing unnecessary calls between the server and client.

5 thoughts on “Get Current User Id Information in Lightning

Leave a Reply

Your email address will not be published. Required fields are marked *