Skip to main content
added 563 characters in body
Source Link
Mohith Shrivastava
  • 92k
  • 19
  • 161
  • 214

You can use userinfo class in apex to obtain the information related to logged in user.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

You can get Id using userinfo.getUserId() and if userinfo class is not able to provide info use query to query those fields .

On VF you will need to use

 <apex:outputText value="{!$User.Id}">

You are using outputfield and hence you are not able to save the code

Edit::

A sample getter setter User object type variable will be handy

public class MailExtension{
  public user currentuser{get;set;}
  public MailExtension(ApexPages.StandardController cont){
     opp =(Opportunity) cont.getRecord();
     currentuser=new User();
     currentuser=[Select Id,Name,Email from User where Id=:userinfo.getuserId()];
  } 
}

A sample VF tag or mark up will be as follows

<apex:outputfield value="{!currentuser.Id}"/>
<apex:outputfield value="{!currentuser.Email}"/>

You can use userinfo class in apex to obtain the information related to logged in user.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

You can get Id using userinfo.getUserId() and if userinfo class is not able to provide info use query to query those fields .

On VF you will need to use

 <apex:outputText value="{!$User}">

You are using outputfield and hence you are not able to save the code

You can use userinfo class in apex to obtain the information related to logged in user.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

You can get Id using userinfo.getUserId() and if userinfo class is not able to provide info use query to query those fields .

On VF you will need to use

 <apex:outputText value="{!$User.Id}">

You are using outputfield and hence you are not able to save the code

Edit::

A sample getter setter User object type variable will be handy

public class MailExtension{
  public user currentuser{get;set;}
  public MailExtension(ApexPages.StandardController cont){
     opp =(Opportunity) cont.getRecord();
     currentuser=new User();
     currentuser=[Select Id,Name,Email from User where Id=:userinfo.getuserId()];
  } 
}

A sample VF tag or mark up will be as follows

<apex:outputfield value="{!currentuser.Id}"/>
<apex:outputfield value="{!currentuser.Email}"/>
Source Link
Mohith Shrivastava
  • 92k
  • 19
  • 161
  • 214

You can use userinfo class in apex to obtain the information related to logged in user.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

You can get Id using userinfo.getUserId() and if userinfo class is not able to provide info use query to query those fields .

On VF you will need to use

 <apex:outputText value="{!$User}">

You are using outputfield and hence you are not able to save the code