+ Start a Discussion
gsickalgsickal 

Open custom link in same window?

How do I get a custom link to open up in the same window it was launched from?  Normally when I click on a custom link, it opens up the code it calls in a completely new salesforce window that is identical to the source window except for the new context in the iframe...
hemmhemm
Instead of having your custom link be to a URL, make the custom link reference an S-Control.  Before you do that, you have to create the s-control.  Use the following code for it.  Where it says {URL GOES HERE}, replace that with the URL value you were putting into your custom link already.  All this does is clean up the frames and replace the entire frame with what is in your URL.  Once you create that, make your custom link and reference that s-control you created.

Code:
<script language="JavaScript">

function redirect()
{
parent.frames.location.replace("{URL GOES HERE}");
}

redirect();

</script>

 

gsickalgsickal

Excellent suggestion.  But my custom link did reference an scontrol and everything works nicely when the custom link is clicked from within the "Custom Links" part of the detail page.  The problem is I have created a formula field so that this custom link appears conditionally in a new section of the layout I created called "Actions".  The formula field looks at the value of a dropdown, and if it is a certain value then it displays the custom link; otherwise it hides it.  Here is the formula field where the link id below ("00b30000000vyG9") is the id of my custom scontrol:

IF (AND (NOT{!Non_Standard__c}, ISPICKVAL({!Status__c}, "Request")), HYPERLINK("/servlet/servlet.Integration?lid=00b30000000vyG9"&"&eid="&{!Id}, "View Draft"), NULL)

I think maybe that the problem is the Hyperlink function above always creates a new salesforce window when what I really want is to have the content of my scontrol (which I specified to open in a salesforce iframe) open in the same window, not a new one...  Is there any way to get this to open in the same window using a formula field like the one described above?  If not, is there any way to have a regular custom link appear conditionally based on some condition?  Thanks

hemmhemm


gsickal wrote:

I think maybe that the problem is the Hyperlink function above always creates a new salesforce window when what I really want is to have the content of my scontrol (which I specified to open in a salesforce iframe) open in the same window, not a new one...  Is there any way to get this to open in the same window using a formula field like the one described above?  If not, is there any way to have a regular custom link appear conditionally based on some condition?  Thanks


I think you are correct in your assumption.  The HYPERLINK function opens in a new window.  Custom links cannot appear conditionally and they also must be contained in their own specific page layout section.
gsickalgsickal

ok, this is what I was afraid of... Thanks very much for your help.

To summarize this for others who might  be helped by this, custom links cannot be conditional, but the advantage of them is they can open up in the same window.  To make them "conditional", you can use a formula field to conditionally hide or show them, but when you do this, they will always open up in a new window since the Hyperlink command (which is the link type field currently available for formula fields) always opens a new window.

Ron HessRon Hess
Stated another way:

HYPERLINK() formula function does not accept any normal browser window open arguments, and always opens a popup.

there is a feature request to provide control over this window open operation.
gsickalgsickal
Thanks very much Ron.  I was going to suggest a feature request as well, but looks like you've got it covered.
Marc C.Marc C.
Looks like the Idea was accepted - Yay!

HYPERLINK(link, text, '_self')

http://boards.developerforce.com/t5/General-Development/Help-with-HYPERLINK-formula-field/td-p/75306