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
Diavonna S.Diavonna S. 

Custom Button On Visualforce Page To Toggle Back to Previous View

Hello,

I am working on a project where I have created a page layout for my executives with a custom button taking them to a "full view" VF page that mimics the full standard detail page.  What I'd like to do is create a second custom button that sits on the VF page that will take them back to the "executive" page layout without them having to click a back button or anything like that.  I have a feeling this is possible, but I'm struggling figuring out how to do it.

Any help is greatly appreciated.  Thank you!

Diavonna 
DeepthiDeepthi (Salesforce Developers) 
Hi Diavonna,

You can navigate to the preferred page by clicking on the custom button by adding the URL inthe pagereference.
Please check the sample code for this.
<apex:page Controller="ControllerClass1">
<apex:form >     
        <apex:commandButton value="click me" action="{!click}"/>
</apex:form>
</apex:page>
 
public with sharing class ControllerClass1 {

    public PageReference click() {
        PageReference pref = new PageReference('http://www.google.com');
        pref.setRedirect(true);
        return pref;
    }

}

Hope this helps you!
Best Regards,
Deepthi