+ Start a Discussion
StormConsultingStormConsulting 

How to get the current User ID in a Apex class

How can I get the current Salesforce User ID in an Apex class?

Any help is appreciated!

Chris
Best Answer chosen by Admin (Salesforce Developers) 
hisrinuhisrinu
You can get the current user id like this.

UserInfo.getUserId() which returns the user id of the current user.

All Answers

hisrinuhisrinu
You can get the current user id like this.

UserInfo.getUserId() which returns the user id of the current user.
This was selected as the best answer
StormConsultingStormConsulting
Thanks a lot, that worked perfectly!
sairam n 5sairam n 5
can we use same syntax to get user id in Triggers too?
CNimmaCNimma
Absolutely. In SOQL queries too!