+ Start a Discussion
Jon KeenerJon Keener 

Best way to link to Visualforce page from a custom detail page button

I've created a custom detail page button to go to a Visualforce page by using the following code in an Execute Javascript call:

This is the typical way I've done this in the past for s-controls, etc, so that the outer frames render correctly and you don't get the dual Salesforce tabs.
The problem I'm seeing that that the browser "Back" behavior isn't operating the way you would want.  Since the above is doing a replace, the back button is skipping a page, since it was lost with the replace.
For Example.
On the Home Page - I search for an account
Account List comes up based on Search
I click on the Account I want
I click the button to launch the VF page
When I hit the back button, instead of going back to the Account, I go back the the Account List based on the Search
My question is whether there is a better way to link to a visualforce page via a Detail button that doesn't cause this behavior?
Jon Keener

Lunching from top level buttons I think you are stuck with the history issue you are seeing.

We need a 4th option when setting up these buttons, "Lunch VisualForce Page", and that will not invoke the servlet used to launch scontrols.

A work-around that I used was a formula field button.

HYPERLINK("/apex/MY_VF_PAGE_NAME—ANY_PAGE_REFERENCES , IMAGE("/servlet/servlet.ImageServer–id=DOCUMENT_ID&oid=YOUR_ORG_ID", "Link Name") , "_parent")

 The IMAGE formula is a link to the button that you have in the docs tab. Make the doc external image.