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
ministe2003ministe2003 

Getting RecordTypeID when it's not in controller...

Hello

I've overridden the New page on Campaigns to render different things on a VF page depending on the RecordTypeID but I have a problem.

 

If a profile only has access to one campaign record type then the page doesnt render anything.

My PageBlocks are rendered based on recordtype, ie

 

rendered="{!Campaign.RecordTypeID = 'X'}"

 

 

This works fine for everyone except those who only have access to one record type.

Users who's profile only allows them to access one record type are never presented with the page to choose the campaign record type from a drop down, this seems to be the key - they are taken straight to the New page.

 

The controller seems to have no information in it (I've checked by debugging my apex) including the recordtypeid and this is causing no pageblocks to render.  The question is how can I tell in this situation which page to render?  SalesForce must know somehow what record type we're dealing with because it chooses the correct PageLayout in this situation, so how do i do it in apex/visualforce?

 

Thanks

 

Steven

bmabma

Hi Steven,

 

When the user can chose between different recordType, salesforce don't know which one to provide that's why the selection happen. Once the selection is made, salesforce can then render the appropriate layout accordingly.

 

In your case, after the user select the recordType from the selection page that value is passed to the VF Page as a query param. You can retrieve that value from your controller using

 

ApexPages.currentPage().getParameters().get('RecordType');

Let me know if that solve your issue, or not.

 

billy

ministe2003ministe2003

Should it not be 

ApexPages.currentPage().getParameters().get('RecordTypeID');

Either way;  it doesnt work.  the controller doesnt seem to have any data in it at all at this point!

 

Thanks though