You need to sign in to do that
Don't have an account?
alana_
Get salesforce logged in user
Hello,
I am using the OpenCTI API. One of the methods I could use to possibley obtain the logged in user of Salesforce is the method 'runApex'. So, I created an Apex class below. However, I am unable to get the user. Does anybody know how to successfully obtain the salesforce user from the Apex class. Any ideas?
global class GetCurrentUser{
webService static String getUserName(String name) {
System.debug('User Id: ' + UserInfo.getUserId());
return UserInfo.getUserId();
}
}
Once you have the User Id (from UserInfo.getUserId()), you can use it to query the User object:
All Answers
Once you have the User Id (from UserInfo.getUserId()), you can use it to query the User object:
+1 MJ
Once you get the id, following information can be queried using SOQL query.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_user.htm
Thank you all for your response. It works.
Refer : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_userinfo.htm
Thanks.
String userName = UserInfo.getName();
system.debug(userName);