Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Get salesforce logged in user
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Get salesforce logged in user
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-26-2013 07:46 AM
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();
}
}
Solved! Go to Solution.
Re: Get salesforce logged in user
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-26-2013 08:34 AM
Once you have the User Id (from UserInfo.getUserId()), you can use it to query the User object:
User u = [select Id, username from User where Id = :UserInfo.getUserId()]
Re: Get salesforce logged in user
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-27-2013 01:09 AM
+1 MJ
Once you get the id, following information can be queried using SOQL query.
http://www.salesforce.com/us/developer/docs/api/Co
Re: Get salesforce logged in user
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-27-2013 08:55 AM
Thank you all for your response. It works.

