+ Start a Discussion
AnjaneyluAnjaneylu 

SaveandNew method for standard Controller

HI friends,
My Question is can we implement the SaveandNew method in standard controller ?
if Yes,
Then Help me in this scenario..
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save and new" action="{!SaveAndNew}"/>
            
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Account information">
            
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Then it is raising the error like
[Error] Error: Unknown method 'AccountStandardController.SaveAndNew()'
Thanks and regards,

Anji
ManojjenaManojjena
Hi Anji ,

SaveAndNew method is not there in standard controller .You can achieve this by creating custom method where you can save the record and  reload the same page instead of redirecing to the record detail page .

For more details about the standard controller method you can check below link.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardController_methods.htm   

Let me know if it helps 

Thanks 
Manoj
Eswar Prasad@Sfdc11Eswar Prasad@Sfdc11
HI Anji,
Saveandnew method is not available standard controller better can do extension method inside dml insert and clear example i given to you
Extension
public Account acc{get;set;}
public void saveAndNew(){
insert acc;
acc.clear();
}

Regards
Eswar Prasad