When i change the record type value(technical or no technical) , i need to hide/show email__c, isClassTeacher__c and i need to show filtered picklist values based on record type selection for the filed designation__c. In one word, I am trying to replicate the standard pagelayout behavious(after selecting the record type, some filds will be hidded(paglayout selection) and some picklist vlaues will change. the same behaviour i am trying to make it...i used extension...to add extra functionality only. can anyone please help me.

  <apex:page showheader="true" sidebar="false" id="page" standardController="Managment__c" extensions="Management_Ext1">
        <apex:outputpanel id="one">
            Selected RecordTypeValue---> {!Managment__c.RecordtypeID}

        <apex:pageBlock id="Details">

            <b><apex:outputLabel value="RecordType " for="recType"></apex:outputLabel></b>

            <apex:selectList size="1" value="{!Managment__c.RecordtypeID}" id="recType">
                <apex:selectOptions value="{!RecordTypeValues}" />
                <apex:actionSupport event="onchange" reRender="one" />

            <apex:pageBlockSection columns="1" collapsible="false">
                <apex:inputfield value="{!Managment__c.Name}" required="true" />
                <apex:inputfield value="{!Managment__c.email__c}" />
                <apex:inputfield value="{!Managment__c.isClassTeacher__c}" />
                <apex:inputfield value="{!Managment__c.Date_of_Joining__c}" />
                <apex:inputfield value="{!Managment__c.Designation__c}" />

                <apex:inputfield value="{!Managment__c.Qualification__c }" style="width:220px;height:150px" />

        <apex:outputPanel layout="block">
                <tr style="position: fixed; bottom: 0" align="center">
                        <apex:commandButton value="Save and Close" action="{!SaveandClose}" immediate="true" />


My Extension code:

public with sharing class Management_Ext1 {
         private Managment__c  ManageSingleRecord;
         public string recordtype{get;set;}

         public String selectedRecordTypeValue{ get; set; }
         public String selectedDesignationValue{ get; set; }
          public Management_Ext1 (ApexPages.StandardController stdCtrl) 

            this.ManageSingleRecord =   (Managment__c)stdCtrl.getRecord();

        if(this.ManageSingleRecord != null && this.ManageSingleRecord .Id != null)        
              this.ManageSingleRecord = [   SELECT  Name,email__c,isClassTeacher__c,Qualification__c,Date_of_Joining__c from Managment__c
                                        WHERE   Id = : ManageSingleRecord.Id];       
            this.ManageSingleRecord = new Managment__c();

public List<selectoption> getRecordTypeValues() {
List< selectOption> ls= new list<selectOption>();
ls.add(new selectOption('', '- None -'));
for(Recordtype p:[select id,name from Recordtype where SobjectType='Managment__c']){
ls.add(new selectOption(p.id,p.name));
return ls;

public pageReference SaveandClose()
            upsert this.ManageSingleRecord;
        catch(Exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.ERROR,'Error creating/updating record'));
        PageReference pageRef = new PageReference('/t');

        return pageRef;   

  • 1
    With your current code, when you change the recordtype selection, are you seeing the change reflected inside <apex:outputpanel id="one"> ? Oct 4, 2018 at 20:48

1 Answer 1


You use management__c quite a bit in your VF which is the record provided by the standard controller but in your apex code you create ManageSingleRecord. I think if you change your VF page to use the variable in your extension instead of the variable provided by the standard controller you'll see more success. The standard VF field binding honors record type (I've seen this many times) so what you're doing should work. Lastly, in your else statement new Managment__c() make sure you set a default record type or the list will show all possible values.

If you're still having trouble rather then setting the record type directly into the field the way you are, pass the recordtypeId to apex and set the record type in your object on the backend.

  • Can you please show me how it works for this samle code Oct 12, 2018 at 8:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .