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
kisorekumar mohanraj 4kisorekumar mohanraj 4 

how to redirect to VF page when we click a record?

when i click a account record it shoud redirect to a VF page which displays that records name and phone field,.
Best Answer chosen by kisorekumar mohanraj 4
Ajay K DubediAjay K Dubedi
Hi Kisorekumar,    
You can use in your controller PageReference method setredirect(true).

    public PageReference MethodName(){    
              pagereference ref =new pagereference('/apex/Your VF_Page Name write here');//Paste your vfpage name
               ref.setredirect(true);
               return ref;
         }

You can also use this.
reRender - ID. The particular block will be refreshed.
rendered - Boolean value (if it is true, it displays the block else it will be hidden)         
         
Refer this URL:
http://www.infallibletechie.com/2012/10/difference-between-rendered-renderas.html
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_System_PageReference_methods.htm         

Please let me know if you have any query.
Please mark it as best Answer if you find it helpful.

Thank You
Ajay Dubedi

All Answers

Newbie__SalesforceNewbie__Salesforce
Hello Kisorekumar,

You can use custom buttons to redirect to VF page using content source Visualforce page
kisorekumar mohanraj 4kisorekumar mohanraj 4
yes, but my requirement is to redirect to a VF page when i click the record!!
Rahul.MishraRahul.Mishra
Hi Kishore,

Create a custom button which execute the script, in formula write : window.location = '/apex/youPageName'
 For more information refer this : https://salesforce.stackexchange.com/questions/12832/how-to-call-a-visualforce-page-from-a-custom-button

Mark the answer as solved if it does help you.

Thanks,
Rahul
kisorekumar mohanraj 4kisorekumar mohanraj 4
is there any way to redirect to VF page without creating button, but on clicking the record,.?
Rahul.MishraRahul.Mishra
You mean on detail page of record ?
Ajay K DubediAjay K Dubedi
Hi Kisorekumar,    
You can use in your controller PageReference method setredirect(true).

    public PageReference MethodName(){    
              pagereference ref =new pagereference('/apex/Your VF_Page Name write here');//Paste your vfpage name
               ref.setredirect(true);
               return ref;
         }

You can also use this.
reRender - ID. The particular block will be refreshed.
rendered - Boolean value (if it is true, it displays the block else it will be hidden)         
         
Refer this URL:
http://www.infallibletechie.com/2012/10/difference-between-rendered-renderas.html
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_System_PageReference_methods.htm         

Please let me know if you have any query.
Please mark it as best Answer if you find it helpful.

Thank You
Ajay Dubedi
This was selected as the best answer