+ Start a Discussion
David OvellaDavid Ovella 

How can I do when I save a field go directly to another page?

Can anyone help me please
I have 3 objects "Pre_Factura - OT - Cuenta"
They relations are:
masterRe Pre_Factura --->  OT
lookupRe Cuente --->  Pre_Factura

and I have 3 visualpages, one is call Pre_FacturaPage,
and I want to know if I can go to another page "OTPages" once I save it, kind of like finishlocation in a flow.
but when I go to the other pages go with the information from the object I created before "Pre_Factura"
 
Best Answer chosen by David Ovella
Shaijan ThomasShaijan Thomas
// First VF page
<apex:page controller="First_Second_Thrid_Controller">
<apex:form >
  <!-- Begin Default Content REMOVE THIS -->
  This is your FirstPage <p></p>
  Enter Value and Click Button : <apex:inputText value="{!FirstPageValue}"/> <p></p>
  <apex:commandButton value="GotoSecondPage" title="GotoSecondPage" action="{!GotoSecondPage}"/>
  </apex:form>
</apex:page>
// Second VF Page
<apex:page controller="First_Second_Thrid_Controller">
<apex:form >
  <!-- Begin Default Content REMOVE THIS -->
  This is your new Page: SecondPage <p></p> Frist Page value : {!FirstPageValue} <p></p>
  Enter Value and click Button : <apex:inputText value="{!SecondPageValue}"/> <p></p>
  <apex:commandButton value="GotoThirdPage" title="GotoThirdPage" action="{!GotoThirdPage}"/>
  </apex:form>
</apex:page>
//Third VF page
<apex:page controller="First_Second_Thrid_Controller">
This is your third Page <p></p>
First Page Value : {!FirstPageValue}<p></p>
Second page Value : {!SecondPageValue}<p></p>
</apex:page>
//Common Controller
public class First_Second_Thrid_Controller {

    public PageReference GotoThirdPage() {
    
        PageReference np1 = Page.Thirdpage;
        np1.setRedirect(false); 
        return np1;
    }


    public String SecondPageValue { get; set; }

    public PageReference GotoSecondPage() {
        PageReference np = Page.SecondPage; 
        np.setRedirect(false); 
        return np;
    }


    public String FirstPageValue { get; set; }
}
Check whether it help you. If it answer your question please check best answer
Thanks
Shaijan Thomas

All Answers

Shaijan ThomasShaijan Thomas
Use the same controller for three different pages, ie all the pages refers to same controller, you should set the setRedirect, when you move to the next page
Thanks
Shaijan
Shaijan ThomasShaijan Thomas
// First VF page
<apex:page controller="First_Second_Thrid_Controller">
<apex:form >
  <!-- Begin Default Content REMOVE THIS -->
  This is your FirstPage <p></p>
  Enter Value and Click Button : <apex:inputText value="{!FirstPageValue}"/> <p></p>
  <apex:commandButton value="GotoSecondPage" title="GotoSecondPage" action="{!GotoSecondPage}"/>
  </apex:form>
</apex:page>
// Second VF Page
<apex:page controller="First_Second_Thrid_Controller">
<apex:form >
  <!-- Begin Default Content REMOVE THIS -->
  This is your new Page: SecondPage <p></p> Frist Page value : {!FirstPageValue} <p></p>
  Enter Value and click Button : <apex:inputText value="{!SecondPageValue}"/> <p></p>
  <apex:commandButton value="GotoThirdPage" title="GotoThirdPage" action="{!GotoThirdPage}"/>
  </apex:form>
</apex:page>
//Third VF page
<apex:page controller="First_Second_Thrid_Controller">
This is your third Page <p></p>
First Page Value : {!FirstPageValue}<p></p>
Second page Value : {!SecondPageValue}<p></p>
</apex:page>
//Common Controller
public class First_Second_Thrid_Controller {

    public PageReference GotoThirdPage() {
    
        PageReference np1 = Page.Thirdpage;
        np1.setRedirect(false); 
        return np1;
    }


    public String SecondPageValue { get; set; }

    public PageReference GotoSecondPage() {
        PageReference np = Page.SecondPage; 
        np.setRedirect(false); 
        return np;
    }


    public String FirstPageValue { get; set; }
}
Check whether it help you. If it answer your question please check best answer
Thanks
Shaijan Thomas
This was selected as the best answer