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
riffindusriffindus 

Webapplication development help needed

Hi,

 

I am trying to create a record with user inputs from different visual force page. I got struck in between.

 

like page 1 gets 2 user inputs and then navigate to page 2 and get 2 more inputs and then inserting the records. the problem is all the 4 fields in the record are mandatory. so if i save the fields after first page, it throws DML exception and if i save in page 2 also ith throws because the values of first page are missing.

 

There is no session object in salesforce i guess..what can i do to handle this situation.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
AmitdAmitd

Hi

 

you should use

 

page.setRedirect(false);

 

suppose on page 1 when you click on save or next button your method should be like

 

public pagereference next(){

   pagereference pg = page.yoursecondpagename;

   pg.setRedirect(false); 

  // when you set is as false it will not create new instance of the controller and on second page you will get all the value of the //controller.

   return pg;

}

 

do not do dml operation on page one button click.

 

on second page after populating fields call the action method to do dml operation

 

Hope it will help you