My custom object has different record types and an overwritten edit page.
I want to implement a 'Save & New'- Button on this VF page which redirects my users to the record type selection page.
How can I implement this in my controller extension of the VF page?
Edit:
I tried to implement the solution from DavinC. First it worked fine, but since Summer '14 it redirects me to the Record Type Selector and if I choose a Record Type and press Continue nothing happens.
VF page button:
<apex:commandButton value="Save & New" action="{!doSaveAndNew}"/>
Controller Extension method:
public PageReference doSaveAndNew() {
PageReference result = null;
try {
upsert myObject;
String myObjectEntityId = CustomSettings__c.getAll().values().get(0).txt_myObjectEntityId__c;
result = new PageReference('/setup/ui/recordtypeselect.jsp?ent=' + myObjectEntityId + '+&retURL=myObjectEditPage&save_new_??url=' + myObjectEntityId + '/e');
}
catch(Exception ignore) {}
return result;
}
Best Answer
Take a look at the URL for the recordtype selection page for the object in question. For Opportunity for example, it's:
006/e being the standard Opportunity edit page.
It should be a similar approach for all objects.