I want to display the currently logged in users in my VF page. Calling the following is not allowed:
<apex:outputField label="Raised by" value="{!$User.Id}"/>
I would like to know how else I could display the current user as well as use the details further in my VF controller extension which sends Opportunity data via email:
public class MailExtension
{
private Opportunity opp;
public MailExtension(ApexPages.StandardController cont)
{
opp =(Opportunity) cont.getRecord();
}
public PageReference sendRequest()
{
// Email Stuff from Opportunity Data
Messaging.reserveSingleEmailCapacity(1);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'[email protected]'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('[email protected]');
mail.setSenderDisplayName('John Doe');
mail.setSubject('Opportunity Request : ' + opp.Id);
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Opportunity: ' + opp.Id +' request.\nCurrent logged in user:' + User.Surname );
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
return new PageReference('javascript:window.close()');
}
}