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
Prasanth Reddy MPrasanth Reddy M 

Visualforce page is not redirecting to specific VF pages with associated record types.


For Account, we have few record types. we want to have the related vf page displayed when a specific record type is selected.

However, upon selecting a record type, the below vf page is not directing the VF new record page specific to record type.

We also have a domain for our instance.

Am i missing something here?
<apex:page standardController="Account" extensions="NewAccountExtension" action="{!redirectToNewVFPage}">

public with sharing class NewAccountExtension {

    public String recordTypeId;

    public NewAccountExtension(ApexPages.StandardController std) {


    public Pagereference redirectToNewVFPage(){
        Pagereference pg = null;
        if(ApexPages.CurrentPage().getParameters().get('RecordType') != null){
            recordTypeId = ApexPages.CurrentPage().getParameters().get('RecordType');
            if(recordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Finance_Account').getRecordTypeId()){
                pg = new Pagereference('');

            }else if(recordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Logistics_Account').getRecordTypeId()){
                pg = new Pagereference('');
            return pg;
        return null;

SandhyaSandhya (Salesforce Developers) 

I would suggest you debug your code by placing system.debug after if and if else statements.

Also you can just use '/apex/logi_account'

Refer below document
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards


Prasanth Reddy MPrasanth Reddy M
Hi, i am getting the null pointer excetion. 

Visualforce Error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!redirectToNewVFPage}' in component <apex:page> in page account_redirect: Class.NewAccountExtension.redirectToNewVFPage: line 13, column 1
Class.NewAccountExtension.redirectToNewVFPage: line 13, column 1

can you let me know what i am missing in line 13.