You need to sign in to do that
Don't have an account?
Patrick 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>
If above is not worked use Record Type Id instead of Name,