+ Start a Discussion
Bhushan Mahajan 5Bhushan Mahajan 5 

how to make method of save&new button?.

how to make method of save&new  button?.
please tell me.
 
KaranrajKaranraj
Bhusan - Try the below method in your standard controller extension class.
 
public PageReference saveNew() {
 PageReference pr; 
try{
 con.save(); 
Schema.DescribeSObjectResult describeResult = con.getRecord().getSObjectType().getDescribe();
 pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e'); 
pr.setRedirect(true); 
return pr; 
}catch(Exception e){
 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
 return null; 
}
}

 
Shashikant SharmaShashikant Sharma
Hi,

You should call the save and then reload the page again, you should use 

public PageRefrence saveAndNext() {
// savelogic
// naviagation logic
PageReference pg = ApexPages.currentPage();
pg.setRedirect(true);
return pg;

}