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
sfadm sfdevsfadm sfdev 

Is there a way in Saleseforce to redirect a custom visulalforce page to a standard one?

Hello,

I have created a custom button with associated custom visualforce page.

Everytime the custom button is pressed it opens the custom visualforce page.

What I would like know is how to prevent the custom visualforce to appear every time the custom button is pressed?

Instead I would like to appear the previous standard page and to be able redirect the vf page to the standard one so when the cussom button is pressed NO CUSTOM Visulalforce page TO APPEAR.

Is there a way in Saleseforce to redirect a custom visulalforce page to a standard one?

Thank you
sandeep madhavsandeep madhav
Hi,
Hope this helps,

Your questions is not clear. Let me solver in different ways.

Custom button not to redirect to vf page every time.
   1. Create two buttons one for vf page and other for standard page.
   2. render the button based on condition it should redirect.

Custom Button redirect to standard page
  1. Yes you can rediect to standrard page.
  2. You can redirect from class using page reference by getting object prefix.


Mark this as the best answer if its helpful.
 
Apoorv Saxena 4Apoorv Saxena 4
Hi,

Yes , its very much possible to redirect to a standard page from a custom command button click on visualforce page.

For eg:

If you want to open any standard record detail page let's say account standard record detaile page then you could do something like this:
 
<apex:commandbutton value="Redirect To Account" action="{!redirectToAccount}"/>

and in your controller :
 
public pageReference redirectToAccount(){
    PageReference pg = new PageReference('/'+AccountID); 
    pg.setRedirect(true);
    return pg;
}

Hope this helps !

Let me know if you have any issues, else mark it question as solved so that others can view it as a proper solution.

Thanks,
Apoorv