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
SpunkySpunky 

Render VF Page based on Record Types

I have a custom object with 4 record types.Each RT has a custom VF page and I want to replace the standard "View" so that each record type displays it's respective VF page.

 

I was using a formula based, page include methid (pasted below) which was working but I changed something and can't seem to fix it. It now renders the same VF page for both RT's.

 

<apex:page standardController="Sales_Tool__c">
<apex:outputPanel rendered="{!IF(Sales_Tool__c.RecordTypeId!='012S00000004SX5',true,false)}">
<apex:include pageName="Assessment_Form" />
</apex:outputPanel>
<apex:outputPanel rendered="{!IF(Job_Aid__c.RecordTypeId!='012S00000004SX0',true,false)}">
<apex:include pageName="CompellingEvent_Form" /> 
</apex:outputPanel>
</apex:page>

Can someone please help me figure what's wrong this?I have a deadline to deploy this so any help would be appreciated. 

 

If you're wondering why I'm not using all apex class/page sample from the cookbook, the reason is I've inherited an sfdc environment where there poor test coverage for existing code and until that's fixed,I cant do anything new.

 

Apex page action may be the answer, I did toy around with that but I'm not too familiar with VF and couldn't quite get that to work. 

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
shruthishruthi

Hi

 

Try using a 18 digit id for the RecordTypeId in the same code [I have marked the last three characters with "*"]

 

<apex:page standardController="Sales_Tool__c">
<apex:outputPanel rendered="{!IF(Sales_Tool__c.RecordTypeId!='012S00000004SX5***',true,false)}">
<apex:include pageName="Assessment_Form" />
</apex:outputPanel>
<apex:outputPanel rendered="{!IF(Job_Aid__c.RecordTypeId!='012S00000004SX0***',true,false)}">
<apex:include pageName="CompellingEvent_Form" /> 
</apex:outputPanel>
</apex:page>

You can check out here in http://forceguru.blogspot.com/2010/12/how-salesforce-18-digit-id-is.htm or you can try in system log by trying this:

List<RecordType> rt = [select id from RecordType where id = 'the 15-digit id that you have in hand'];

system.debug(rt); // you can get the 18-digit id here.

All Answers

shruthishruthi

Hi

 

Try using a 18 digit id for the RecordTypeId in the same code [I have marked the last three characters with "*"]

 

<apex:page standardController="Sales_Tool__c">
<apex:outputPanel rendered="{!IF(Sales_Tool__c.RecordTypeId!='012S00000004SX5***',true,false)}">
<apex:include pageName="Assessment_Form" />
</apex:outputPanel>
<apex:outputPanel rendered="{!IF(Job_Aid__c.RecordTypeId!='012S00000004SX0***',true,false)}">
<apex:include pageName="CompellingEvent_Form" /> 
</apex:outputPanel>
</apex:page>

You can check out here in http://forceguru.blogspot.com/2010/12/how-salesforce-18-digit-id-is.htm or you can try in system log by trying this:

List<RecordType> rt = [select id from RecordType where id = 'the 15-digit id that you have in hand'];

system.debug(rt); // you can get the 18-digit id here.

This was selected as the best answer
Rahul SharmaRahul Sharma

In rendered attribute of outputPanel, you are checking with two different Field/Object Names, may be that can be the issue.

 

<apex:page standardController="Sales_Tool__c">
<apex:outputPanel rendered="{!IF(Sales_Tool__c.RecordTypeId!='012S00000004SX5',true,false)}">
<apex:include pageName="Assessment_Form" />
</apex:outputPanel>
<apex:outputPanel rendered="{!IF(Job_Aid__c.RecordTypeId!='012S00000004SX0',true,false)}">
<apex:include pageName="CompellingEvent_Form" /> 
</apex:outputPanel>
</apex:page>

 Hope it helps.

SpunkySpunky

That was it! The 18 digit record type id worked. Thank so much.

BibhuBibhu

Hi I have an requirement where I am stuck. I want to display values of a picklist based on record type in Visual Force Page.

I have an Scontrol which directs the User to the VF page after he selects the record type and clicks on continue button. However I find all the values present in the picklist is displayed to the user ,  picklist value is not getting filtered based on the record type he select.

Scontrol which over-rides New Button is

 

<script type="text/javascript" src="/static/013008/js/functions.js"></script><script type='text/javascript' src='/soap/ajax/13.0/connection.js'></script><script src="/soap/ajax/13.0/apex.js" type="text/javascript"></script> <script  src="/dJS/en/1213010380000/library.js" type="text/javascript"></script><script type="text/javascript"

src="/static/013008/desktop/desktopAjax.js"></script><script type='text/javascript'>

 

 

if('{!$Profile.Name}'=='RE_Austria _FieldSales_User' || '{!$Profile.Name}'=='REAustria_BUM_Profile' || '{!$Profile.Name}'=='REAustria_Product_Manager' || '{!$Profile.Name}'=='REAustria_Sales_Manager' ||'{!$Profile.Name}'=='System Administrator')

{

window.parent.location.href='/apex/Sample_New_Related_List?ent={!BXEU_Samples__c.Id }&RecordType={!BXEU_Samples__c.RecordTypeId}';}

 

else

{

window.parent.location.href=window.parent.location.href+'&nooverride=0';

}

</script>

 

 

 

Ane help would be appreciated.

Rahul SharmaRahul Sharma

Whats the error which you are getting?

ghouseghouse

Hi bindu,

 

I have a requirement, In that i need to display record types in vf page just like standard page. When i select record type then associated page should be displayed.

 

Thanks in Advance...