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
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;

}