thanks @kevan

When the User clicks on the Custom link on a page layout, new tab should open routing to the url as formulated in the controller. VF page is behind the custom link. I dont want to use a JAVASCRIPT, as we are in the verge of moving towards lightining.

Targer attribute (command button and link ) or javascript (windows.open) wont work out.

VF Page

<apex:page standardController="Asset" extensions="LaunchAssetButtons_CTRL" action="{!launchCTMOBRequest}" >
<apex:pageMessages ></apex:pageMessages>
<apex:outputPanel >
<script> window.open('{!url}', '_blank'); </script>
<apex:sectionHeader title="Open Salesforce Case and Pop Page"/>   
<apex:outputPanel >If you see this page

Contoller method

public string url {get;set;} 

Public string launchCTMOBRequest(){
url = 'www.google.com';
return url;

This VF page is the the engine behind the of a custom link. enter image description here enter image description here

when ever i click on this link , a new tab should open with the above URl. I want to use only VF page not JAVA script button.

Can someone please help ?

  • 2
    Your requirement is not clear, am bit confused on what you want to achieve.
    – Raul
    Commented Feb 12, 2017 at 17:06
  • 1
    Please see How to Ask to get the most from the Community. There's way too much code posted here as most of it is irrelevant to your issue. Simplify your problem to its essence
    – cropredy
    Commented Feb 13, 2017 at 3:13
  • You need to use either target or JavaScript. You can't specify a target in the PageReference class. There simply is no other way.
    – sfdcfox
    Commented Feb 13, 2017 at 3:57

2 Answers 2


I have achieved the above requirement , while creating the custom button , we can choose 'Open in new window' option and this solves my problem.

Thank you all for your valuable time :-) Venkatesh


I would recommend the following changes in your code. Instead of returning a pagereference assign the link to a variable.

public string url {get;set;} 

Then in your visualforce page, add the following code:

<apex:outputPanel rendered="{! NOT(ISBLANK(url)) }">
<script> window.open("{!url}", "_blank"); </script>

So when your action is executed and populate the "url" variable, it should redirect to your url.

Hope it helps. Check my blog for tips and tricks about Salesforce https://kevansfdc.blogspot.com

You must log in to answer this question.

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