How to get current User Id using Apex in Salesforce?

UserInfo.getUserId() - returns the current User Id

Sample Code:

User Usr = new User();

Usr = [SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()];

the above code will return the current user's Phone and Id who execute this code.


1 comment:

Sharing is Caring!!! Share this with your friends!!!

submit to reddit