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
Force2b_MikeForce2b_Mike 

Override Opportunity Save Functionality on New Record

I am trying to figure out a way to effectively redirect the user to a VisualForce page after a new opportunity is created, while passing in the ID of the new Opportunity. The overall objective is to require the user to enter additional information about the Opportunity on a separate screen. I'd also like to avoid completely recreating the Opportunity edit page in VF so that the admins can still add/change fields and use the PageLayout Editor.

 

My thought was that I could use the standard Opportunity Controller on a VF page and then use <apex:detail>, however it doesn't seem like it's possible to call an Apex page for a new record unless you're manually building the form. For example:

 

  • https://na6.salesforce.com/006/e?retURL=/apex/OppPart2/id=newOppID - This would redirect the user to a specific page after the save has completed, but there's no way to know the newOppID ahead of time.
  • https://na6.salesforce.com/apex/NewOpportunity/e - Calling a VF page with the standard /e at the end fails with an error
  • https://na6.salesforce.com/apex/NewOpportunity?ID= - Calling a VF page with a blank ID parameters displays a blank screen.


Does anyone know of a way to either:

  • Override the [Save] button functionality on a New Opportunity without recreating the entire edit form in VF?
  • Create a VF page that can determine the ID of the Opportunity just created
  • Any other way to have display a specific VF page after creating a new opportunity?


Thanks for your help.

 

Mike

Force2b_MikeForce2b_Mike

FYI - I was able to resolve this issue by redirecting the VIEW page for the Opportunity to a custom VisualForce page. The new VF page is very straight forward. It uses the apex:detail tag to display the standard page layout for the user. The key is the Action= attribute on the Apex:page tag. This calls a method in the extension controller that redirects the user to another custom page the first time a record is saved. It requires a new custom field with a default value set to something, such as TRUE or 1. The subsequent page just needs to reset that custom field value when it's done.

 

 

<!-- * Shell View Page for an Opportunity that automatically redirects to * the appropriate Next Step upon creating a new opportunity. * This uses the correct Page Layout based on the users Profile. --> <apex:page standardController="Opportunity" extensions="NewOpportunityWizard" title="Opportunity: {Opportunity.Name}" action="{!IsNewOpportunity}" > <apex:detail /> </apex:page>

 

 Mike

 

mallikammallikam

Mike,

 

This is something similar to what I was trying to do. I want to override the standard opportunity save button and I have written the below VF page(oppextension) that would overirde view of Opportunity.

apex:page standardController="Opportunity" extensions="OppExtension" action="{!validatePartnerFields}"> </apex:page>

 

The validatePartnerFields is supposed to redirect the user to another VF page(partnerdetails) that contains partner details if one of the values on Opportunity page is yes..but my problem is, when I overirde view with the above page, any type of view is being redirected to partnerdetails page! I dont want it, I just want the page to be redirected when the user hits save button on opportunity(be it new opp or existing opp) and when a particular field on opportunity is yes. Otherwise, I would prefer the normal details page..any help?

 

thanks!

Terry411Terry411

Mike, I know this is an older post but I'm trying to do this same type of thing and redirecting the Opportunity Save to the Opportunity Contact Role.  I feel like I'm close to getting this to work but would you still have the Extension code you used and be willing to post it?  That might help me solve my problem.