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
bensondanielbensondaniel 

Overiding Standard Pages

Hi there, 

 

I have a scenario in my org to Override the standard New Account creation page with a custom VF Page for certain record types. 

The VF Page should only appear for a set of record types and should not appear for the rest. For the rest of the record types the standard New Account page should appear. 

 

Please could you advise me on the design strategy I should go about in doing this? 

 

At the moment I am overriding the standard 'New' button in Account 

 

using the following VF Page

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

VF Code

<apex:pagetitle="New Account"standardController="Account"tabStyle="Account"extensions="New_Account_Controller"action="{!pullToPage}">

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Controller

 

public PageReference pullToPage(){

     PageReference pageRef;

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

     User currentUser = [SELECT Id, Name, UserRole.Name, Profile.Name FROM User WHERE Id =: UserInfo.getUserId() limit 1];

        

     if(selectedRecordTypeId == null){

          if(currentUser.Profile.Name.contains('GV')) {

                 accountRecTypeName='MY Account RT';

                 selectedRecordTypeId = [SELECT Id, Name FROM RecordType WHERE Name =: accountRecTypeName limit 1].Id;                

          }

     }else{

            accountRecTypeName = [SELECT Id,Name FROM RecordType WHERE Id =: selectedRecordTypeId limit 1].Name;

     }   

            

        if (accountRecTypeName == 'MY Account RT'){

            pageRef = null;

        }else if(selectedRecordTypeId != null){

            pageRef = new PageReference('/001/e?');

            pageRef.getParameters().put('RecordType', selectedRecordTypeId);

            pageRef.getParameters().put('nooverride', '1');

        }else{

            pageRef = new PageReference('/001/e?');

            pageRef.getParameters().put('nooverride', '1');

        }

        return pageRef;

    }

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

This seesms to work fine but given that I am working with a huge user base, this strategy seems to considerably reduce the preformance of other record type users.

Everytime a different recordtype other than MY Account RT is used, salesforce has to execute the above controller and then the user is redirected to the original standard page.

This is time consuming and seems to be an over kill given that we have to just override one record type among many.

 

Please could you suggest an alternative solution to this?

 

Many Thanks in Advance

 

VennilaVennila

Hi. You don't need to replace the new button. Because that visualforce page will appear in all record types. 

 

So, you can use inline visualforce page for particular record type page layout.