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
nnknnk 

Save & New

Hi,

 

I want to replicate the Save & New button futionality in my vf page. See my comments in the code.

 

public with sharing class SaveNew {
private ApexPages.StandardController solnController;
private final EP_Action__c action;
    public SaveNew(ApexPages.StandardController controller) {
       solnController = Controller;
       action = (EP_Action__c)controller.getRecord();
    }
public PageReference savenew()

{    
     solnController.save();
    PageReference page = new pagereference('/a0J/e');----> I dont want this hard coded. any alternative way?
    page.setRedirect(true);
    return page;
          
}
}

bob_buzzardbob_buzzard

You should be able to reference the edit page from the standard controller.

 

PageReference page=solnController.edit();

 

nnknnk

Thanks for reply,

however i dont want the edit page, i want to redirect to New page.

bob_buzzardbob_buzzard

So you do!  I just saw the /e in the URL and assumed that you wanted the edit!  Sorry about that - I should read posts more carefully.

 

There doesn't seem to be a simple way to access this, as the controllers don't expose it.  The $Action global variable has a new property that you can use on a page:

 

{!URLFOR($Action.Account.New)}

 

so you could probably create something that sends this back to the controller from the page, but its less than elegant.