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 

Save button not working on Visualforce Page V2

Hello
I have created two visualforce pages A and B and assign them to 2 record types, using an apex class. It works properly, the only problem I have is when clicking save button on the visualforce page, both save the record in the same record type (A). Is anyone able to identify what am I missing? Thank you. 

VISUALFORCE PAGE A
<apex:page standardController="ADELTESurvey__c" lightningstylesheets="true">
  <h1>CUSTOMER SATISFACTION SURVEY - DELIVERY</h1>
  <apex:form >
  
  <apex:pageBlock title="Customer Information">
  <apex:pageBlockSection columns="2">
   <apex:inputField value="{! ADELTESurvey__c.Contact__c}"/>
   <apex:inputField value="{! ADELTESurvey__c.Account__c}"/>
   <apex:inputField value="{! ADELTESurvey__c.Opportunity__c}"/>
   <apex:inputField value="{! ADELTESurvey__c.Survey_date__c}"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
<apex:commandButton action="{! save }" value="Save" />
  
</apex:form>
</apex:page>

VISUALFORCE PAGE B
<apex:page standardController="ADELTESurvey__c" lightningstylesheets="true">
  <h1>CUSTOMER SATISFACTION SURVEY - OPERATION</h1>
  <apex:form >
  
  <apex:pageBlock title="Customer Information">
  <apex:pageBlockSection columns="2">
   <apex:inputField value="{! ADELTESurvey__c.Contact__c}"/>
   <apex:inputField value="{! ADELTESurvey__c.Account__c}"/>
   <apex:inputField value="{! ADELTESurvey__c.Opportunity__c}"/>
   <apex:inputField value="{! ADELTESurvey__c.Survey_date__c}"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
<apex:commandButton action="{! save }" value="Save" />

</apex:form>
</apex:page>

VISUALFORCE REDIRECT
<apex:page standardController="ADELTESurvey__c" extensions="NewSurveyExtension" action="{!redirectToNewVFPage}" lightningstylesheets="true">
</apex:page>

APEX CLASS
public class NewSurveyExtension {

    public String recordTypeId;

    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.ADELTESurvey__c.getRecordTypeInfosByName().get('Delivery').getRecordTypeId()){
                pg = new Pagereference('/apex/Satisfaction_Survey_Delivery'); // Add Parameters to Page if Needed

            }else if(recordTypeId == Schema.SObjectType.ADELTESurvey__c.getRecordTypeInfosByName().get('Operation').getRecordTypeId()){
                pg = new Pagereference('/apex/Satisfaction_Survey_Operation'); // Add Parameters to Page if Needed
            }
            pg.setRedirect(true);
            return pg;
        }
        return null;
    }