+ Start a Discussion

How to Override "Save and New" Functionality in Standard Edit Page

How to override the"Save and New" Button Functionality which is in Standard Edit Page




Thanks ,




<apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save" id="xyzz"/>
                <apex:commandButton action="{!Save}" value="Save & New" id="saveAndNew"/>
                    <apex:param name="newAndSave" value="newAndSave" />
                <apex:commandButton action="{!cancel}" value="Cancel"/>



    public PageReference save() {
        Id id = controller.getId();
        Boolean saveAndNew = false;
        for(String key : Apexpages.currentPage().getParameters().keySet()){
                saveAndNew = true;
            return new PageReference('/'+controller.getRecord().getSObjectType().getDescribe().getKeyPrefix()+'/e');
            return controller.view();

Bhawani SharmaBhawani Sharma
You can not override SaveAndNew functionality from standard page. You will have to override your Edit page first, then you can build your logic for SaveAndNew.