0

I have a two simple visualforce pages which used to get data from users, i used a standard controller with common extension controller. The record got created but the data from the second page is not saved, i checked the field level security, everything looks good. Please help me on this

Visualforce page 1:

<apex:page standardController="Empower_Application__c" extensions="MPEmpowerController" showHeader="false" sidebar="false" cache="false" title="PartnerEmpower Program" tabStyle="Empower_Application__c">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection title="PartnerEmpower Program">
            <apex:inputField value="{!MPE.Region_Requested__c}"/>
            <apex:inputField value="{!MPE.Referring_Distributor__c}"/>
            <apex:inputField value="{!MPE.Relationship_Type__c}"/>
            <apex:inputField value="{!MPE.Technology_Segment_Interest__c}"/>
        </apex:pageBlockSection>
    <apex:pageBlockButtons location="bottom">
         <apex:commandButton id="save" action="{!NextPage2}" value="Next"/>
    </apex:pageBlockButtons>  
     </apex:pageBlock>         
</apex:form>

Visualforce Page 2:

<apex:page standardController="Empower_Application__c" extensions="MPEmpowerController" showHeader="false" sidebar="false">
<apex:form >
    <apex:pageBlock id="pageblock" helpTitle="Click here for help" helpUrl="https://www.google.com" >
        <apex:outputPanel >
            <apex:outputLabel value="* Fields bordered in red indicate required fields" style="font-weight: bold; font-size: 1.3em; color: #000000;"></apex:outputLabel>
        </apex:outputPanel>
        <apex:pageBlockButtons >
            <apex:commandButton immediate="true" action="{!prevPage1}" value="Pervious"/>
            <apex:commandButton immediate="true" action="{!Save}" value="Save"/>
        </apex:pageBlockButtons> 
        <apex:pageBlockSection collapsible="false" showHeader="true" title="Applicant Details"/>
        <apex:pageBlockSection columns="2" collapsible="false">
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Salutation}" />
                <apex:inputField value="{!MPE.Applicant_Salutation__c}" required="true" taborderhint="1" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Title}" />
                <apex:inputField value="{!MPE.Applicant_Title__c}" required="true" taborderhint="5" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_First_Name}" />
                <apex:inputField value="{!MPE.Applicant_First_Name__c}" required="true" taborderhint="2" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Phone_Number}" />
                <apex:inputField value="{!MPE.Applicant_Phone_Number__c}" required="true" taborderhint="6" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Last_Name}" />
                <apex:inputField value="{!MPE.Applicant_Last_Name__c}" required="true" taborderhint="3" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Mobile_Number}" />
                <apex:inputField value="{!MPE.Applicant_Mobile_Number__c}" taborderhint="7" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Email_Address}" />
                <apex:inputField value="{!MPE.Applicant_Email_Address__c}" required="true" taborderhint="4" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem labelStyle="text-align: left; padding-bottom: 15px;">            
                <apex:outputLabel value="{!$Label.Applicant_Primary_Language}" />
                <apex:inputField value="{!MPE.Preferred_Language__c}" required="true" taborderhint="8" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

Extension controller:

public class MPEmpowerController {
    public ApexPages.StandardController controller;
    public String AppID {get;set;}

    Empower_Application__c EmpwrApp = new Empower_Application__c();

    public MPEmpowerController(ApexPages.StandardController controller) {
        this.controller = controller;
        EmpwrApp = (Empower_Application__c)controller.getRecord();
    }    

    public Empower_Application__c getMPE(){

        AppID = ApexPages.currentPage().getParameters().get('id');

        if(EmpwrApp.Id == null && AppID != null){
                EmpwrApp = [Select Id, Region_Requested__c,Referring_Distributor__c,Relationship_Type__c,Technology_Segment_Interest__c,Applicant_Salutation__c,Applicant_Title__c,Applicant_First_Name__c,Applicant_Phone_Number__c,Applicant_Last_Name__c,Applicant_Mobile_Number__c,Applicant_Email_Address__c,Preferred_Language__c from Empower_Application__c where id =:AppID]; 

        }
        return EmpwrApp;
    }

    public PageReference nextPage2(){    
        return page.MPEPage2;    
    }

    public PageReference prevPage1(){
        return page.MPEPage1;    
    }

    public PageReference save(){
        EmpwrApp.Status__c ='New';
        upsert EmpwrApp;
        return null;
    }
}
8
  • did you get any error ?
    – Safiya PV
    Commented Apr 27, 2017 at 6:03
  • no..only the field values from the first page got saved. Commented Apr 27, 2017 at 7:10
  • data not saved from first page or second?
    – Safiya PV
    Commented Apr 27, 2017 at 7:12
  • in first page you are not saving the data directly you are going to second page.
    – Safiya PV
    Commented Apr 27, 2017 at 7:14
  • correct, but the data from the first page got saved but not from the second page Commented Apr 27, 2017 at 8:10

1 Answer 1

0

i removed immediate="true" in command button, now data saved from second page also..

You must log in to answer this question.

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