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
ravalipothineni1.3549438248976ravalipothineni1.3549438248976 

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 ,

Ravali

priyaforsfdcpriyaforsfdc

Page

<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"/>
            </apex:pageBlockButtons>

 

 Class:

    public PageReference save() {
        Id id = controller.getId();
        controller.save();
        Boolean saveAndNew = false;
        for(String key : Apexpages.currentPage().getParameters().keySet()){
            if(key.contains('saveAndNew')){
                saveAndNew = true;
                break;
            }
        }
        if(saveAndNew){
            Apexpages.currentPage().setRedirect(true);
            return new PageReference('/'+controller.getRecord().getSObjectType().getDescribe().getKeyPrefix()+'/e');
        }
        else
            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.