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
Ricardo Aguilar 4Ricardo Aguilar 4 

Edit button redirecting to visualforce pages not working

Hello,

I have assigned two Visualforce Pages to two different record types using the following code and controller.

Codes work properly when creating a new record, using the "New Survey" button. (See image below)

I also have overriden the Edit button to launch the Visualforce Page to edit the record, but when clicking the edit button it doesn't show anything. It is not working.

"Edit" button actually used to work properly in the past, but now it turn out to be that I have might forgotten something in the code for this button.

Any help would be appreciated!
VF Code
User-added image

Apex code
User-added image

Edit button 
User-added image

User-added image
Madhukar_HeptarcMadhukar_Heptarc
Hi Ricardo,

I understand your requirement.
Public ID recordTypeId; // Can you please change the data Type String To ID because
RecordTypeID = apexpages.currentpage().getParameters().get('RecordType'); // When you are geting record type from URL it will return ID 
Public class NewSurveyExtension
{
	Public ID recordTypeId;
    public Hospital_Application__c Happ {get;set;}
	Public NewSurveyExtension(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.Hospital_Application__c.getRecordTypeinfosByName().get('New Record').getRecordtypeID())
			{
				pg= new PageReference ('/apex/HApp_New_Record');
			}
			else if(RecordTypeID == Schema.SObjectType.Hospital_Application__c.getRecordTypeinfosByName().get('Existing record').getRecordtypeID())
			{
				pg= new PageReference ('/apex/HApp_Existing_record');
			}
			pg.setRedirect(true);
			return pg;
		}
		return null;
	}
}
Please let me know if you need any help/if it helps you.

Thanks & regards 
Madhukar.
 
Ricardo Aguilar 4Ricardo Aguilar 4
It didn't work. I still receive page in blank when clicking the edit button.
It works for a new record though, like previous code.

User-added image