OVERRIDE THE STANDARD BUTTON WITH PURE CONTROLLER

This post talks about how to override the standard buttons with pure controller or wizard pages, its a trick that I recently found.

The requirement: When we hit the new button from Accounts/ Contacts/ Opportunities it should call same wizard. 

Solution One:
The Normal way is to create three wizards for overriding respective buttons, like, create a the wizard from the following link 
"http://developer.force.com/cookbook/recipe/creating-a-wizard-with-visualforce-pages
with small modifications, saying -- standardController="Account" extensions="newOpportunityController" instead of custom controller. and the we would continue to create two more pages to override contacts and opportunities. the solutions looks good but we can save those two pages with this little tweak. 

Solution Two:
Step 1: Continue creating visualforce page 1 with standad controller and an extension, then go to accounts buttons and links and override the new button with the page.

Step 2:Come back to the same page and just change standard controller "Account" to "Contact", now the same page is available for contact's buttons to override. Override the new button.

Step 3: Come back to the same page and change standard controller "Contact" to "Opportunity". override the opportunity new button too.

Step 4: Now is the trick, change the visualforce page back to its original state, meaning, put the controller back, The page should have Controller, not Standardcontroller. 

:)

Its done.

you can now check by clicking the new buttons from "create new" or from object home tab, same page comes on to the display.


Comments

Popular posts from this blog

Lightning spinner inside Button

Passing URL parameters to controller in Lightning components/ AURA

Nested AURA:IFs in Lightning Components Salesforce