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
Abi V 4Abi V 4 

How to Reload the URL onclick of the button salesforce

Onclick of the commnad link i need to refresh the viasulforce page(overrriden to vf  tab) URL .
Please suggest me how to acheive this.
 
Keyur  ModiKeyur Modi

Hi Abi, 

If you want to redirect page through custom controler then you can do it with help of PageReference. for more detail you can follow this blog  (http://blog.jeffdouglas.com/2008/11/14/redirecting-users-to-different-visualforce-pages/)
 

<apex:page>
<apex:commandLink action="{!doRedirect}" value="Save" id="theCommandLink"/>

</apex:page>


Public Class Controler1 {

Public pageReference doRedirect(){
      PageReference opportunityPage;
       //add your logic
      opportunityPage = new PageReference('/' + opp.id); // here I am redirecting this one to opportuntiy detail page.
return pageRefrence;
}

}
 



If you want to achieve that through javascript then you can try with below snippet of code :- 

<apex:Page>
<script>
    function toRedirect() {
        window.location.href="https://google.com";
    }
    </script>
<apex:commandLink  value="Save" id="theCommandLink" onClick=''toRedirect();"/>

</apex:page>

Please let me know if you need more informaiton on this.

Thanks, 
Keyur Modi