
VisualForce Page:
<apex:page standardController="Reservation__c" extensions="ReservationClass" >
<apex:sectionHeader title="New Reservation" />
<apex:form >
<apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!order.User__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Custom Controller
public class ReservationClass {
public Reservation__c res{get; set;}
public String FName = UserInfo.getFirstName() ;
public String Lname = UserInfo.getLastName();
public string UserName = FName + ' ' + Lname ;
public ReservationClass (ApexPages.StandardController stdController) {
res = (Reservation__c) stdController.getRecord();
res.User__c = userName ;
}
}
The above code throws an error
"Invalid id: Shravya Rama An unexpected error has occurred. Your development organization has been notified."
Hi Shravya Rama 9, You will have to assign the user id to the User__c field. Pls try assigning the userinfo.getUserId().