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
BrokenBirdBrokenBird 

Loading a custom tab programatically

I am trying to load a tab programatically, so far I use the url that I see when I click on the tab, but I want to make sure this is the correct way:

 

 

public PageReference GoToTab() { PageReference pageRef = new PageReference('/servlet/servlet.Integration?lid=01r800000003iF1&ic=1'); return pageRef; }

 

Will that also work in a deployed managed application at a customer's site?

 

Thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
XactiumBenXactiumBen

I'm not sure whether the tab id will be the same when deploying to another salesforce account (probably not since all object tabs end up being different) so you can't really rely on it.  A better way would be to load up the Visualforce page that is the tab page:

 

public PageReference GoToTab() { PageReference pageRef = Page.myTabPage; return pageRef; }

 

 

I'm not sure that you can reference the tab directly.

All Answers

dfalsodfalso

I'm currently trying to get a delete action to work correctly, and have been using this page. The author describes URLFOR and notes that it can be used for tabs:

 

http://salesforcesource.blogspot.com/search?updated-max=2009-01-02T14%3A33%3A00-05%3A00&max-results=1

 

 

[All that is to say, I haven't tried it] 

XactiumBenXactiumBen

I'm not sure whether the tab id will be the same when deploying to another salesforce account (probably not since all object tabs end up being different) so you can't really rely on it.  A better way would be to load up the Visualforce page that is the tab page:

 

public PageReference GoToTab() { PageReference pageRef = Page.myTabPage; return pageRef; }

 

 

I'm not sure that you can reference the tab directly.

This was selected as the best answer
BrokenBirdBrokenBird
Thanks, that was exactly what I was looking for.
craigmhcraigmh

This code does redirect the user to the VisualForce page.  However, the correct tab is not selected (the Home tab is).  This is confusing for users.  If anyone knows how to redirect to a specific VisualForce page with a certain Tab selected (I'm surprised it's not easy, since you can set up a Tab to show a specific VisualForce page), I'd appreciate.

 

If I find the solution myself first, I'll be sure to post it here.  Thanks in advance.

craigmhcraigmh
For the time being, I've persisted the sfdc.tabName parameter.
Rajesh UnadkatRajesh Unadkat

Anyone with better solution? I am having similar issue. I would like to avoid using tab number.

 

thanks,

-rajesh