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
SalesforceDF2011SalesforceDF2011 

Overiding Save button on the Detail Object

Hi,

 

I have a custom object which is on the detail side of the Opportunity object. When the user goes to the related list thru the Opportunity and click new, he is directed to the Edit page of the custom object. When the user hits save i would like to redirect them back to the Opp page.

 

Does anyone know how this can be achieved.

 

Thanks!


raseshtcsraseshtcs

I have a method to do this but this will not be useful only if the child record is being created from the opportunity and not from the tab

override the view of the custom object with a visualforce page and then in the action of the page write method which will redirect the user to the parent opportunity instead of the record itself.

 

In case the record is being created from tab then also the user will be redirected to the parent opportunity of the record.

<apex:page standardController="Custom_object__c" extensions="redirect" sidebar="true" action="{!todo}">
  
 </apex:page>

 

public class redirect{  
  public redirect(ApexPages.StandardController controller)
   {  
   
    }

    public PageReference todo() 
    {     
    //get opptyid here
     pageRef = new PageReference('/'+opptyid);
     
    
     return pageRef;   
    }