I have a VF page embedded in standard page layout, "source." when the user clicks a button that is in the VF Page, he should get sent to a new page "destination".

Problem: the destination page is opening within the VF section of the page layout- "source" This only occus when the user is not in development mode.


<apex:pageBlock rendered="{!IF(ISNULL(record) , true , false)}">
  <apex:pageBlockSection columns="1" title="Analysis"/>
     <apex:commandButton value="Create Strategies" action="{!createNewRecord}"/>


 public pageReference createNewRecord(){
        PageReference p;
        String s = '/a0K/e?CF00Ne0000000fqjP=' + this.record.name + '&retURL=' + this.record.id;
        p = new PageReference(s);
        p = p.setredirect(true);
        return p;


You need to tell the page to have the parent page redirect, not the VF page that you are currently interacting with.

Add this your VF page

<apex:outputPanel id="redirectPanel" >
     <apex:outputText rendered="{!shouldRedirect}">
          <script type="text/javascript">
               window.top.location.href = '{!url}';

And change your commande button to

<apex:commandButton value="Create Strategies" action="{!createNewRecord}" rerender="redirectPanel"/>

And make these adds/changes in your controller

public boolean shouldRedirect           {get;set;}{shouldRedirect = false;}
public string url                       {get;set;}

public PageReference createNewRecord(){
     url = '/a0K/e?CF00Ne0000000fqjP=' + this.record.name + '&retURL=' + this.record.id;        
     shouldRedirect = true;
     return null;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.