UserInfo.getUserId() - returns the current User Id
Sample Code:
User objUser = new User();
objUser = [ SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId() ];
system.debug( 'User Id ' + objUser.Id );
system.debug( 'Phone ' + objUser.Phone);
The above code will return the current user's Phone and Id who execute this code. Execute the code in Anonymous window.
very used full content.
ReplyDeleteYour posts are really helpful. Thank you for that!
ReplyDelete