I need to override the standard 'New' button with a VF page.

Based on the record type selection, I am able to redirect to different pages.

now my challenge is to decide the VF page redirection based on PageLayout assignment(both record type and profiles) not based on RecordType alone.

I'm not sure if this is possible in Salesforce. Can anyone pls let me know the solution/work around?


2 Answers 2


I think there are three general approaches you can take here:

  1. (Preferred) Use the $Profile global variable, in conjunction with detecting the Record Type either from URL Parameters or from the object' RecordType.Name field, in a giant case statement. For instance, the following page could be used to override the Account object's New action, assuming that there are Account record types and that you are not skipping the Record Type selection screen in your override:

    <apex:page standardController="Account" action="/apex/{!CASE($Profile.Name,
        'System Administrator',
               'Industrial Account','NewIndustrialAccount_SystemAdmin',
               'Education Account','NewEducationAccount_SystemAdmin',
              'Healthcare Account','NewHealthcareAccount_SystemAdmin','DefaultNewAccount_SystemAdmin'
        'Sales Manager',
               'Industrial Account','NewIndustrialAccount_SalesManager',
               'Education Account','NewEducationAccount_SalesManager',
               'Healthcare Account','NewHealthcareAccount_SalesManager','DefaultNewAccount_SalesManager'
           'Industrial Account','NewIndustrialAccount_Default',
           'Education Account','NewEducationAccount_Default',
           'Healthcare Account','NewHealthcareAccount_Default','DefaultNewAccount_SystemAdmin'
  2. (Complicated and probably not worth it) Use the Web Services API's describeLayout call from within JavaScript in a "dispatcher" page to retrieve an object's actual Page Layout Assignments and then use these to redirect to appropriate Visualforce Pages.

  3. Use a 3rd party tool like Skuid to manage the creation of custom interfaces to override standard actions --- Skuid's Page Assignments feature is specifically designed to assist in providing this sort of dispatch functionality for custom Visualforce interfaces.
  • Did my answer help in solving your problem? If so please vote up so that others will benefit.
    – zachelrath
    Dec 27, 2012 at 15:22

You can deal with this redirect inside the controller, if you use an init method in your page:

<apex:page controller="TheController" action="{!Init}" ... 

Simply check the RT provided and then redirect the user if it doesn't match the one you're interested in:

public PageReference Init()
    // Grab the ID (or IDs in a list of the RT we don't want to redirect:
    Id objRTId = [select Id from RecordType where SObjectType = 'TheObj__c' and DeveloperName = 'TheRT' limit 1][0].Id;
    String chosenRT = ApexPages.CurrentPage().GetParameters().Get('RecordType');

    // If no match, then redirect to the standard page by using 'nooverride=1'
    if(chosenRT != objRTID)
        // redirect to the standard new screen
        String url = '/' + TheObj__c.SObjectType.GetDescribe().GetKeyPrefix() + '/e?RecordType=' + chosenRT + '&nooverride=1';

        return new ApexPages.PageReference(url).SetRedirect(true);

    return null;

Note that instead of using override=0 or sfdc.override=0 as you might expect from looking at the URL of the Visualforce page, the parameter to use is nooverride which must be set to 1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .