I need to make a create flow for a custom object in which the user picks some options which sets some properties on the object. The properties that will be set will be removed from standard layouts so the user doesn't change them after the object is created.
After this happens I want to display the standard edit screen for the custom object and let it go through the standard edit flow and let the user set other properties.

Currently I have this working by extending the standard controller. And I override the "new" to go to my custom Visual Force page. On that page the user picks some values and based on that, properties on the object are set on the button action.

At the end of the action I do

    <Create my "og" object and set some properties based on choices on the VF page>
    insert og;
    return new PageReference('/' + og.Id + '/e?retURL=%2F'+og.Id);

So I create the object, set some properties, insert it, and call edit with a return URL of view. This works in Classic but breaks in Lightning Experience in that after the "save" in edit I get the message that the object was saved but the app goes to the "home" screen not to the view of the created object like in Classic or like what happens on standard Salesforce objects in Lightning.

I don't want to do the URL hack even with going to the edit. I would like to know if there's a better way in APEX to call the standard edit view after you create(new) the object than the URL Hack?

  • I tried this instead for the last line: return new ApexPages.StandardController((Custom__c)og).edit(); Based on a comment on this answer link The redirect to edit happens but the problem is the retURL is set to my VisualForce page not a standard view page
    – HungryPipo
    Jan 17, 2017 at 18:28


You must log in to answer this question.

Browse other questions tagged .