I am using this query on apex:

    public static string GetUserEmail(string userid)
    String usrid = UserInfo.getUserId() ;
    string queryString= 'select Id,name,Email from User where id=:usrid';
           return queryString;


But now I do not know how to get this id on visualpage.

  • what do you want on VF page? current user details ? Commented Aug 17, 2016 at 9:46

2 Answers 2


Depending on exactly what you are trying to do you might need not any code (it's unclear why you using a remote action), you could use the Global Variable $User:


For example:

  <h1>User Info Page</h1>
   This is your new Apex Page
   <p>UserId: {!$User.Id}</p>
   <p>User Email: {!$User.Email}</p>

Use the $User Global variable to get the details of the current logged in user in your Visualforce page.

To get the Id use {!$User.Id}

Hope it helps.

  • No it is give me id but m using knocout js here when i got userid than on this id base i got only this user email
    – user29407
    Commented Aug 17, 2016 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .