0

I want to display a section based on the record type,

<apex:page standardController="Interviewers_Feedback__c" extensions="ControllerFeedback">
<apex:form id="theForm">
    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!QuickSave}" rerender="theForm" />
        </apex:pageBlockButtons>
        <apex:messages />
        <apex:pageBlock >  
            <apex:pageBlockSection >
                <apex:selectList value="{!Interviewers_Feedback__c.RecordTypeID}" >
                    <apex:selectOptions value="{!RecordTypes}" />
                </apex:selectList>
                <apex:inputField value="{!Interviewers_Feedback__c.Job_Application__c}"/>
                <apex:inputField value="{!Interviewers_Feedback__c.Name}"/>
            </apex:pageBlockSection> 
            <apex:pageblock >
                <apex:pageBlockSection title="CEO" >
                    <apex:inputField value="{!Interviewers_Feedback__c.CEO_Comments__c}"  rendered="{!Interviewers_Feedback__c.RecordType='CEO'}"/>
                    <apex:inputField value="{!Interviewers_Feedback__c.CEO_Conclusion__c}" rendered="IF(Interviewers_Feedback__c.RecordType='CEO',true,false)" />  
                </apex:pageBlockSection>   
            </apex:pageblock> 

            <apex:pageblock >
                <apex:pageBlockSection title="HR">
                    <apex:inputField value="{!Interviewers_Feedback__c.HR_Comments__c}"/>
                    <apex:inputField value="{!Interviewers_Feedback__c.HR_Conclusion__c}"/>                       
                </apex:pageBlockSection>   
            </apex:pageblock>

            <apex:pageblock >
                <apex:pageBlockSection title="Technical"> 
                    <apex:inputField value="{!Interviewers_Feedback__c.Technical_Comments__c}"/>
                    <apex:inputField value="{!Interviewers_Feedback__c.Technical_Conclusion__c}"/>
                </apex:pageBlockSection>   
            </apex:pageblock>
        </apex:pageBlock>
    </apex:pageBlock>
</apex:form>

public class ControllerFeedback {
    Interviewers_Feedback__c t;
    ApexPages.StandardController controller;
    public ControllerFeedback(ApexPages.StandardController controller) {
        this.controller = controller;
        t = (Interviewers_Feedback__c) Controller.getRecord();
    }
    public list<SelectOption> getRecordTypes() {
        list<SelectOption> options = new list<SelectOption>();
        for (list<RecordType> rts : [SELECT ID, name FROM RecordType WHERE SObjectType = 'Interviewers_Feedback__c' ORDER BY name]) 
        {
            for (RecordType rt : rts) {
                options.add(new SelectOption(rt.ID, rt.Name));
            } 
        }
        return options;
    }
}

1 Answer 1

1

You can use rendered on pageblocksection based on the record type

<apex:pageBlockSection rendered="{!Interviewers_Feedback__c.RecordType.Name== 'opt1'}">

With in single pageblock, you can have 2 apex:pageBlockSection for 2 record types.

1
  • Hey Rashmi, I tried the above code you given but than too its not happening Commented Jan 6, 2020 at 9:54

You must log in to answer this question.

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