You need to sign in to do that
Don't have an account?
Asif Khan 44
Redirecting to the VF page based on record type selected
I have a student custom object and i have two record types for that, i want to create a VF page where user can select the record type and after pressing a button on that same page he should get redirected to another VF page which contains fields according to the record type selected and there i can fill the details which should get reflected to the database.
object - Student__c
Record types - Technical and Non technical
object - Student__c
Record types - Technical and Non technical
Check the condtion like this.
If(Recordtype.name == Technical){
// Use the page reference method to redirect another visualforce page.
}
Let me know if you need any help regarding this.
Thanks,
Vijay
VF Page Code
Controller Code
Let me know if you need any help.
Thanks,
Naval
thanks,
Asif
here is my code
<apex:page Standardcontroller="Student__c" Extensions="TransactionSiteController" >
<apex:form >
<apex:outputPanel id="MainPanel">
<apex:pageBlock >
<apex:outputPanel > <!--rendered="{!rend}"-->
<apex:pageBlock >
{!rend}
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Transfer" action="{!editWithRecordType}" rerender="pb" />
</apex:pageBlockButtons>
<apex:pageBlockSection collapsible="false" columns="1">
<apex:inputField value="{!Student__c.RecordTypeId}"/>
<apex:inputhidden value="{!Student__c.Last_Name__c}" />
<apex:inputhidden value="{!Student__c.First_Name__c}" />
<apex:inputhidden value="{!Student__c.Extra_Curricular__c}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel id="pb">
<apex:pageBlock rendered="{!rend}">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Student__c.First_Name__c}"/>
<apex:inputField value="{!Student__c.Last_Name__c}"/>
<apex:inputField value="{!Student__c.Subject__c}"/>
<apex:inputField value="{!Student__c.Extra_Curricular__c}"/>
<apex:commandButton action="{!save}" value="Update"/>
<apex:commandButton value="Back" onclick="window.history.go(-1)"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
controller
public class TransactionSiteController {
public Boolean rend { get; set; }
public Student__c proxy { get; set; }
public TransactionSiteController(ApexPages.StandardController controller) {
rend = false;
this.proxy = (Student__c)controller.getRecord();
}
public PageReference editWithRecordType() {
rend = true;
return null;
PageReference nextPage = new PageReference('/apex/demo');
nextPage.getParameters().put('RecordType', proxy.RecordTypeId);
return nextPage;
}
}