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
dfcdfc 

Apex Navigation to Top Level Tabs

How do you navigate to a specific top-level (standard object or custom object) tab from Apex? Not to a specific instance of an SObject, but to the top-level tab/list.

 

Thanks!


Dave

 

Best Answer chosen by Admin (Salesforce Developers) 
jlojlo
I think that you're going to have to use the describe() call. See here: http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=5812
Message Edited by jlo on 02-04-2010 10:35 AM

All Answers

jlojlo

Have you tried using the $Action Global Variable?

 

 

From Help:

 

 

$Action Description: A global merge field type to use when referencing standard Salesforce.com actions such as displaying the Accounts tab home page, creating new accounts, editing accounts, and deleting accounts. Use action merge fields in LINKTO and URLFOR functions to reference the action selected. Use: 1. Select the field type: $Action. 2. Insert a merge field, such as $Action.Account.New. Visualforce Example: <apex:outputLink value="{!URLFOR($Action.Account.New)}">Create New Account</apex:outputLink> Tips: This global variable is only available for custom buttons and links, s-controls, and Visualforce pages.

 

 

 

Message Edited by jlo on 02-01-2010 06:11 PM
dfcdfc

Thanks for trying to help.  Can you show me what you are getting at with code?  I see the tantalizing reference in the help (to the accounts tab home page), but have no idea what Apex syntax would make this happen...

 

Thanks.

 

Dave

 

 

 

jlojlo

It should be relatively obvious how you can generate the url for a tab using the $Action global variable in VF, but it sounds like you want an Apex-based solution. Is that correct? If so, why? What is it that you're trying to do? Do you have some sample code? (It doesn't need to work.)

 

 

 

 

dfcdfc

jlo -- Yes, I want to do it in Apex.

 

I have a VF page button that should navigate the user to one of two top-level tabs, depending on business logic.  A simple concept.  One of the top-level tabs is a VF page, so I can get there no problem.  The other one is the default tab for a custom object, so there is no VF page name I can employ in the URL to get there...

 

Can anyone from SFDC weigh in on this?  I have scoured all documentation and googled myself to death.  Simply put (again), how do you navigate to a top-level tab in Apex???

 

Thanks,


Dave

 

jlojlo
I think that you're going to have to use the describe() call. See here: http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=5812
Message Edited by jlo on 02-04-2010 10:35 AM
This was selected as the best answer
dfcdfc

Perfect!  Thanks. 

 

Based on your suggestion, this works just fine:

 

Schema.DescribeSObjectResult r = MyCustomObject__c.sObjectType.getDescribe();
String prefix = r.getKeyPrefix();
ApexPages.PageReference p = new PageReference('/' + prefix + '/o');
return p;
 

 

Rajesh ShahRajesh Shah

Hi,

 

This is ok for a Std or Custom object tab. But what if the tab is a visualforce or web tab? Is there any way to navigate to it dynamicallty instead of hardcoding?

 

Regards,