How can I display the selected record type name in my vf page even though it is not totally inserted yet?
Note: I am using salesforce's standard record selection.
Someone told me to use before insert in apex trigger, but I am not so used to it. Can anyone show me how to execute this?
Meanwhile, here are my controller and visualforce page:
Controller:
public class TheController {
private ApexPages.StandardController controller;
public Object__c obj {get;set;}
public List<Object__c> objList {get;set;}
public TheController(ApexPages.StandardController con) {
controller = con;
this.obj = (Object__c)controller.getRecord();
Object__c obj = new Object__c();
List<Object__c> objList = new List<Object__c>();
}
public PageReference save() {
objList = new List<Object__c>();
Object__c__c obj2 = new Object__c();
obj2.Field1__c = obj.Field1__c;
obj2.Field2__c = obj.Field2__c;
obj2.Field3__c = obj.Field3__c;
obj2.Field4__c = obj.Field4__c;
objList.add(obj2);
if(!objList.isEmpty()) {
insert objList;
}
PageReference pg = new PageReference('/' + obj2.Id);
pg.setRedirect(true);
return pg;
}
}
Visualforce Page:
<apex:page standardController="Object__c" extensions="TheController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!obj.Field1__c}"/>
<apex:inputField value="{!obj.Field2__c}"/>
<apex:inputField value="{!obj.Field3__c}"/>
<apex:inputField value="{!obj.Field4__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>