2

I am using this query on apex:

  @RemoteAction
    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.

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

2 Answers 2

5

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:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_global_user.htm

For example:

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

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.

1
  • 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 .