3

I am trying to build a custom New Case page, but am having issues getting sections to load based on the Record Type.

<apex:outputField label="Record Type: " value="{!Case.RecordTypeId}"/>
<apex:pageBlockSection rendered="{!Case.RecordTypeId == 'SFDC Request'}" columns="1">

   <apex:outputText>This is the new case page for SFDC Request record layout.</apex:outputText>

</apex:pageBlockSection>

The above code outputs the correct record type in the first line (the outputField), but the BlockSection does not render. I have also tried using {!Case.RecordType.Name} but that does not work either (in either the render or the outputField).

Here is what is displayed when SFDC Request record type is selected using the above code snippit:

enter image description here

Any suggestions as to why this is not working?

Trying RecordType.Name:

<apex:page StandardController="Case">

    <apex:form >
        <apex:pageBlock title="New Case" mode="edit" >

            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel" onclick="window.close()"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection columns="1">
                <apex:outputField label="outputField Case.RecordTypeId is: " value="{!Case.RecordTypeId}"/>
                <apex:outputText label="outputText Case.RecordTypeId is: "> {!Case.RecordTypeID}</apex:outputText>
                <apex:outputField label="outputField Case.RecordType.Name is: " value="{!Case.RecordType.Name}"/>
                <apex:outputText label="outputText Case.RecordType.Name is: ">{!Case.RecordType.Name}</apex:outputText>

            </apex:pageBlockSection>

            <apex:pageBlockSection rendered="{!Case.RecordType.Name == 'SFDC Request'}" columns="1">

                <apex:outputText >This is the new case page for SFDC Request record layout.</apex:outputText>

            </apex:pageBlockSection>

        </apex:pageBlock>
    </apex:form>
</apex:page>

Results:

enter image description here

  • Are you using a controller extension? That is a place where you can get hold of the ID values you need if your page needs to work across multiple orgs. – Keith C Oct 22 '14 at 17:11
3

{!Case.RecordTypeId == 'SFDC Request'} can never work since RecordTypeId is Salesforce-Id in the form of '012b0000009nNoA' which will never equal to 'SFDC Request'

However if you use it within an apex:outputField the platform may show you the name implicitly. This is possibly the reason, why you are a bit confused. Try to use apex:outputText instead to dump the real value.

Your approach using {!Case.RecordType.Name} looks way better. Try to output this via apex:outputText. Does it output 'SFDC Request'? If so, try to use the IF() formula inside the {!....} token instead of the == operator.

  • Everything I have found suggests that RecordType.Name should be what I need, however, that does not seem to be working in practice. Having issues with the commenting system - I will add additional detail to the original question. – AaronC Oct 22 '14 at 20:10
0

This is a little late. I was having the same issue and I tried implementing the above solution which did work but then I realized the Record Type ID I was grabbing from the URL in setup was actually a truncated version. Perhaps it's the same for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.