function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patrick C Mayer 91Patrick C Mayer 91 

Render based on RecordType VisualForce

I can't figure out how to check the RecordType in the rerender.
public class SubmitCaseController {
	
	public Case c { get; set; }
	
	public String acctNum { get; set; }
	
	public SubmitCaseController() {
		c = new Case();
	}
    
	public PageReference submitCase() {
		List<Account> accts = [SELECT Id FROM Account WHERE AccountNumber = :acctNum];
		if (accts.size() != 1) {
			ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Invalid account number');
			ApexPages.addMessage(msg);
			return null;
		} else {
			try {
				c.AccountId = accts.get(0).Id;
				
				// now look for an associated contact with the same email
				Contact cnt = [SELECT Id FROM Contact WHERE AccountId = :c.AccountId AND Email = :c.SuppliedEmail LIMIT 1];
				if (cnt != null) 
					c.ContactId = cnt.Id;
					
				// Specify DML options to ensure the assignment rules are executed
				Database.DMLOptions dmlOpts = new Database.DMLOptions();
				dmlOpts.assignmentRuleHeader.useDefaultRule = true;
				c.setOptions(dmlOpts);

				// Insert the case
				INSERT c;
				return new PageReference('/thanks');
			} catch (Exception e) {
				ApexPages.addMessages(e);
				return null;
			}
		}
	}
<apex:page controller="SubmitCaseController">    
    <apex:form >
        <apex:pageBlock title="New Case" id="thePageBlock" mode="edit">
        <table>
            <tr>
                <th>
                    Type:
                </th>
                <td>
                    <apex:inputField value="{!c.recordTypeId}">
                    <apex:actionSupport event="onchange" rerender="thePageBlock" status="status"/>
                    </apex:inputField>
                </td>
            </tr>
            <tr>
                <th>
                    <apex:pageBlockSection rendered="{!c.recordType.name == 'Auto Notification'}">
                    TEST
                    TEST
                    TEST
                    </apex:pageBlockSection>
                </th>
            </tr>
        </table>
        </apex:pageBlock>
    </apex:form>

</apex:page>



Arunkumar RArunkumar R
Change the above visualforce code to like below,
<apex:outputPanel rendered="{!IF(c.recordType.Name == 'Auto Notification',true,false)}">

<apex:pageBlockSection >

                    TEST

                    TEST

                    TEST
 </apex:pageBlockSection>

</apex:outputPanel>

If above is not worked use Record Type Id instead of Name,

<apex:outputPanel rendered="{!IF(c.RecordTypeId == '012C0X120004SX0',true,false)}">

------- Your content ---------------

</apex:outputPanel>