You need to sign in to do that
Don't have an account?
eliotstock2
accessing the user object within a custom controller or standard controller extension
Hi there.
Is there any way to get access to the User object from within a custom controller or an extension to a standard controller? It seems strange that I have it in the VF page but not in the controller.
Thanks,
Eliot Stock.
Yes, you can access the User object in Apex (ie controller). You could use the UserInfo methods or query the User object for a specific dataset:
//just an example List<User> users = [select id, username from User LIMIT 10];
All Answers
Yes, you can access the User object in Apex (ie controller). You could use the UserInfo methods or query the User object for a specific dataset:
//just an example List<User> users = [select id, username from User LIMIT 10];
And to get the user of the page -
public User me = [SELECT ID, Name FROM User WHERE ID = :userInfo.getUserId()];