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
sancasanca 

set redirect issue

Hi All ,

I have a VF page which is a standard controller(opportunity) with extension . It has a form with some input text fields and next button ,
Next button calls pagereference method which redirects the page to std edit pagelayout of opportunity(setRedirect(false)) .In the url I have also mentioned retURL which points to the VF page .
So my query is when I fill  some text fields and clicks on next button , it redirects to opp edit page . Now when I click on cancel button, It takes me to vf page but the form values are missing . 
Can anyone tell me why the view state is missing or getting flushed out when i return back to VF page using cancel button .
Note : The form is html form , not a  <apex:form> .

As per salesforce doc , "if set to false, the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page."

My source page is VF page (std cont -opp with ext) and target page is opportunity edit page .So here controller are the same . So it has to work as per the doc ? or am I missing something here
LBKLBK
I believe Viewstate is available for Visualforce pages only. Can you not replace the Edit Page Layout with another VF Page instead?
sancasanca
Hi , Yeah ur right , View state is only VF page , The page what i am talking is about source vf page which has form . The target is std edit page opp layout . I cant replace std edit page with  avf page as there are 4 record types/4 page layout in opp object which has to be maintained .
I am concerned when i go back to source page from target page by clicking on cancel button .
LBKLBK
I am not very clear about your use case, but, is your VF page having input fields related to Opportunity object?

Can you not save these information in to the object, instead of retaining them in viewstate, when the user clicks Next button?

This way, you can reload the data, when the user clicks on cancel button.
sancasanca
Its not a input fields related to opportunity . its just a html text fields . What i am doing is that i am passing these user typed values and prepopulating these using url . But my concern is when user is on edit page layout and clicks on cancel button , it will be directed to the vf page which has that form and form values disappears . What i want is to retain that form values when std cancel button is clicked from edit page . 
Hope ur clear right now.