I have used actionfunction to redirect visualforce page to another page but the page is not redirecting into another.

VF Page:

<apex:commandButton value="Create" onclick="createfunction()" />
   function createfunction(){
        <!-- some operations -->
<apex:actionFunction name="create" action="{!create}" reRender="">
     <apex:param name="one" value="" assignTo="{!value1}" />
     <apex:param name="two" value="" assignTo="{!value2}" />

Apex Controller:

Public PageReference create(){
     PageReference oppPage = new PageReference('/'+oppId);
     return oppPage;   

Can any one help me how can i resolve this issue.

  • Any errors in your browser's console? Also, have you tried changing the commandButton to plain HTML input? Commented Apr 11, 2016 at 6:34
  • I didn't get any console errors. I tried by replacing command button with html input button, but still same problem am facing. Commented Apr 11, 2016 at 6:50
  • Is the apex method getting called at all? Chuck a system.debug there and double check. And try move the action function above your script Commented Apr 11, 2016 at 6:52

3 Answers 3



<apex:commandButton value="Create" onclick="createfunction(); return false;" />
  • Can you add some explanation to your post?
    – Adrian Larson
    Commented Jul 21, 2016 at 13:30

Just use input button instead of command button and you need to use two action functions one for calling controller method and the other one for redirecting to another page after the first action function has been completed:

<apex:form id="form">
   <apex:actionFunction name="doSmthng" action="{!doSomething}" reRender="optpnl" oncomplete="gotopg();">
      <apex:param name="paramName" value="" />

  <apex:actionFunction name="gotopg" action="{!gotoMyPage}"/>

<apex:outputPanel id="optpnl">
   <input type="button" value="Do Something" onclick="doSmthng();"/>

inside the controller:

public void doSomething(){
  String prm = ApexPages.currentPage().getParameters().get('paramName');

public PageReference gotoMyPage(){
   return Page.myPage;


Is there any specific reason of using actionFucntion? Why not direct commandButton with params?

<apex:commandButton value="Create" action="{!classActionMehthod}" reRender="panelId">
<apex:param name="anyName" value="anyValueOrBlank" assignTo={!classVariable}"/>
  • You have to keep "reRender" in the button syntax to keep param working.
  • Keep it blank or surround your page code in and give panel id.

Hope this works.

  • OP's question references a create action and your answer uses 'delete'. Answer is a bit confusing. If you mean to show a generic commandbutton, perhaps changing to <apex:commandButton value="Foo" action="{!someAction}" reRender="someID">
    – cropredy
    Commented Jun 17, 2016 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .