0

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:outputPanel>
<apex:sectionHeader title="Open Salesforce Case and Pop Page"/>   
<apex:outputPanel >If you see this page
</apex:outputPanel> 
</apex: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 Feb 12 '17 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 Feb 13 '17 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 Feb 13 '17 at 3:57
0

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

|improve this answer|||||
-1

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>
</apex:outputPanel>

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

|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.