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
Carlton BrumbelowCarlton Brumbelow 

How do I have a custom visualforce button redirect to a standard 'New' page? (problem: getting the right URL)

My problem is very specific. I know how to make a button redirect. Here's my setup and the problem

Setup:
  • Custom visualforce page with an apex:commandButton that calls an action in my controller. 
  • Controller has the appropriate PageReference method. This works, when I have a redirect URL I can get to
  • In my custom object the 'New' button is overridden to navigate to my custom visualforce page
Problem:
  • I want the button on my visualforce page to then redirect to what would normally be the standard page for the 'New' button (when not overrideen), but I cannot find right URL for that page. When I switch the standard action back to the standard page and grabe the URL, it does not work in my code. 
I suspect the URL I'm receiving points to the page of whichever action I choose in my object. Is there a way to grab the actual ID or page reference to the standard page?
Best Answer chosen by Carlton Brumbelow
Carlton BrumbelowCarlton Brumbelow
I got this working. I had to add ?nooverride=1

All Answers

Pradeep SinghPradeep Singh
Hi,
Refer below code,

public pageReference redirectToOriginal(){
        pageReference pg = new pageReference('/a01/e');
        return pg;
 }
Here a01 are the first 3 digits of the ID of record of my objectUser-added image
Carlton BrumbelowCarlton Brumbelow
Thank you for the attempt to help Pradeep. The problem is, while I have the object ID, the /e takes you to whichever page is set as the action for the 'New' button of my object. I'm looking for a way to find the direct path to the standard 'New' page, so I can get to it from my custom page.
Carlton BrumbelowCarlton Brumbelow
I got this working. I had to add ?nooverride=1
This was selected as the best answer