function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MaumanMauman 

Web Link Switch To Custom Tab?

Is there a way to have a web link (say on the Opportunity), switch to a Custom Tab, without popping a new window AND without having a set of nested tabs (2 sets appearing)?
DevAngelDevAngel

Hi Mauman,

The way to do this is with an sforce Control.  Create a simple sforce Control that contains only a single line of javascript as follows:

<script>
window.parent.location.href = "https://na1.salesforce.com/a0P/o";
</script>

Next, create a web link that opens the sforce control.  I would have the web link open inside the frame rather than a new window (in which case the javascript above would need to reference opener) or in the "half screen" option.

The url is the url to my custom tab.

MaumanMauman
But with that solution, I would not be able to pass the variables I need to pass to the page that is on the site that I am linking to. And I apparently cannot read them off the URL because the parent of the IFRAME is in another domain, and thus the browser securtiy prevents it.

e.g. I am trying to pass the opportunity id, so a custom application I am working on that will appear under one of the custom tabs. If they go to the custom tabs, I am showing the 'main' page of the application, but if they click on the link from the opportunity, I want to go to another page that needs that opportunity ID, BUT I also want it to appear as though they are in my Custom Tab, not still under "Opportunities".

Any ideas? Am I stuck in the "Opportunity Tab"?
DevAngelDevAngel

Hi Mauman,

Hmm... I understand what you are trying to do.  I think there is no great solution but a work around might work.

This is a hack, but see if it works.  The hack involves making the web link open an scontrol in a new window.  You pass the oppty id to the scontrol.  In script, you cause the opener page to navigate to the plain Web tab.  After navigating to the web tab, the script in you scontrol window would then redirect the iframe in the web tab to a url on your app server passing the oppty id in that url.  Your scontrol window would then close.  This all relies on using the window.opener object.

So when the scontrol window opens

opener.window.location = <url to web tab>;

opener.window.frames[1].document.location = <your app>?oppId=<oppty id>;

window.close;

????

MaumanMauman

Yes.  That is a 'hack'. 

 

I will have to see if that is acceptable.  If the popup window is at all visible, it probably won't be. I'll let you know if it works IF we decide to proceed with this. 

 

Long term it would be cool if it was a 'feature' in the Web Link settings 

 

Thanks!

MaumanMauman
Thanks for your help DevAngel... I built upon your idea. It is still a bit of a hack, but it appears to work just fine AND does not require a pop-up of any sort (which was unacceptable due to pop-up blockers).

Here is what I did...

1. I have a web link (on an opportunity in my case) that points to a sforce control that contains the following:

- - - - - - - - - - - - - - - - - - - - - - - -

top.window.location='[TAB URL HERE]&op={!Opportunity_ID}';

- - - - - - - - - - - - - - - - - - - - - - - -

This redirects the user to the custom tab WITH the opportunity ID in the top level URL (which the tab page itself ignores).

2. The tab then points to ANOTHER sforce control that pulls out the opportunity ID and appends it to a url, but only if the variable exists. So if you go to the tab directly it will not be passed. The URL stays within the frame and it all seems to work beautifully, giving the appearence that you have switched tabs.

- - - - - - - - - - - - - - - - - - - - - - - -

var sSearch = top.window.location.search.substring(1);
var Parameters = new Object();
var sNameValuePairs = sSearch.split('&');
var sNameValuePair;
var op = "";
for (var i = 0; i < sNameValuePairs.length; i++) {
sNameValuePair = sNameValuePairs[i].split('=');
if(sNameValuePair[0] == "op")
{
op="&op=" + sNameValuePair[1];
}
}
window.location='[MY APPLICATION'S URL HERE]'+op;

- - - - - - - - - - - - - - - - - - - - - - - -

Let me know if you see any issues with this approach other than it 'feels' like a hack.

Thanks again!

Message Edited by Mauman on 05-16-2005 12:06 PM

JakeOlearyJakeOleary
So is there any good way to link to a custom tab and pass in variables that then get passed along to the destination URL?? I read all the related posts, seems strange that you can link directly to content on a custom weblink from the outside.
MaumanMauman

So you did see my solution (below)?   

I'm not sure I follow what exactly you are trying to do.  If the link a weblink on sf.com and you are trying to switch to a custom tab and pass data, that is exactly what my solution does.  I don't know if it is "good" but it has worked for our 50 users for 2 months now, no complaints.

- - - - - - - - - - -

Here is what I did...

1. I have a web link (on an opportunity in my case) that points to a sforce control that contains the following:

- - - - - - - - - - - - - - - - - - - - - - - -

top.window.location='[TAB URL HERE]&op={!Opportunity_ID}';

- - - - - - - - - - - - - - - - - - - - - - - -

This redirects the user to the custom tab WITH the opportunity ID in the top level URL (which the tab page itself ignores).

2. The tab then points to ANOTHER sforce control that pulls out the opportunity ID and appends it to a url, but only if the variable exists. So if you go to the tab directly it will not be passed. The URL stays within the frame and it all seems to work beautifully, giving the appearence that you have switched tabs.

- - - - - - - - - - - - - - - - - - - - - - - -

var sSearch = top.window.location.search.substring(1);
var Parameters = new Object();
var sNameValuePairs = sSearch.split('&');
var sNameValuePair;
var op = "";
for (var i = 0; i < sNameValuePairs.length; i++) {
sNameValuePair = sNameValuePairs[i].split('=');
if(sNameValuePair[0] == "op")
{
op="&op=" + sNameValuePair[1];
}
}
window.location='[MY APPLICATION'S URL HERE]'+op;