function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chamil MadusankaChamil Madusanka 

Current user Id in apex class

Hi,

 

How can I get current user Id in apex code? I tried {!$User.Id}. But it didn't work. How to resolve it?

 

Thanks in Advance

Best Answer chosen by Admin (Salesforce Developers) 
nbknbk

Hello,

Can you try this

UserInfo.getUserId()