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
SuvraSuvra 

Overriding "Save & New" button on Opportunity edit page

Hi,

 

I need to override "Save & New" button on Opportunity edit page. But, there should not be any change in the "New" button on Object Home Page in terms of functionality.

 

Either "Save & New" needs be removed or it should not allow creating new records.

 

Any idea how to go about it??

 

Please help.. Thanks in Advance,

 

Suvra

werewolfwerewolf
That button is not overrideable as of this writing.  You can override the New functionality but you can't override buttons on the Edit page.
CTU007CTU007

Maybe create your own opportunity edit page, and then define your buttons there.

 

then override the standard edit button with this page. 

 

SuvraSuvra

Thanks for your ideas..  

AdyAdy

Hi,

 

This may help: http://community.salesforce.com/sforce/board/message?board.id=general_development&message.id=32238

 

If you want to override the save and new then use the variable 'save_new' in the URL ie add 'save_new=<call page/s-control/file>' to your URL

Anil SutarAnil Sutar

Following is generic code uses Standard Save functionality for any object object.

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

 

 

    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();
    }

Jayanth ThathapudiJayanth Thathapudi
@Ady

Your solution worked for me.Thanks:)

Thanks
Jay
Neeraj Sethi 7Neeraj Sethi 7

Hi

Using Master Lookup we can solve this problem.

Thsnk you