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
SnardSnard 

When clicking "Save" for new related list item, return to parent page?

Hi,

 

I apologize in advance if this is an often repeated request; I've been searching the message base for the past 30 minutes and can't find any related threads.

 

I have created a VisualForce page to override the behavior of the "New" button on a related list. This page works fine, except that when the "Save" button on the page is clicked, it takes me to the view page for the record I just created. I want to take the user to the original page (which contains the related list), just as would happen if I click the "Edit" button next to a related list item. Is there an easy way to do this? I assume I will either need to create a new controller to replace the StandardController, or I'll need to create a controller extension. If there is an example for this that someone could point me to, I would be forever grateful.

 

Thanks,

 

  - Mike

Imran MohammedImran Mohammed

Use PageReference and redirect it to the parent page.

In your apex code, in the save functionality, create page reference with the parent page URL and set redirect to true and return the page reference.