It's very easy open the detail page of a new record created in a custom controller of a visual force page.

Example code:

public PageReference save() {
        PageReference acctPage = new PageReference('/' + Influencer.id);
        return acctPage;

But i would like to be able to open the page of the new record in edit mode.

Please, can you help me?

Thanks in advantage for any advice.

1 Answer 1


All you have to do is attend '/e' (edit). Adding the retURL parameter will take an url to which the page should navigate on save and cancel actions. If you don't add this the page will default to going to the homepage.

PageReference acctPage = new PageReference('/'+ID+'/e?retURL=%2Fa'+ID);

will do what you want. Not sure if there are more dynamic ways to get that.

  • 6
    You can also do this: public PageReference save() { return new ApexPages.StandardController(Influencer).edit(); } This has the advantage of using the standard utility that forms the correct link for you; if salesforce.com changes their behavior later, this code will still get the correct url.
    – sfdcfox
    Aug 17, 2013 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.