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
bdardinbdardin 

Problem Overriding Custom Object Tab

I am trying to override the tab of a custom object to a Visualforce. I am using a Standard Set Controller in the page. All the documentation I've found said it is possible to override a tab with a Standard Set Controller, but the page doesn't show up in the Visualforce page drop down. Is there something I'm missing as to why it's not showing up?

 

Visualforce page code:

 

<apex:page standardController="SVMXC__Installed_Product__c" recordSetVar="installedproducts" extensions="PortalTabRedirectController" action="{!redirect}">
    <apex:enhancedList type="SVMXC__Installed_Product__c" height="700" rowsPerPage="50" customizable="false"/>
</apex:page>

Extension code, in case that's relevant - I purposely wrote it to be not specific to any object, as we are trying to override the tab for multiple objects in the same way. Basically we want the standard tab to show for all users except for our Customer Portal users, who instead will only see the enhancedList just showing all the records, instead of the Recently Viewed list.

 

public with sharing class PortalTabRedirectController {
    public String keyPrefix;
    
    public PortalTabRedirectController(ApexPages.StandardSetController stsc) {
        SObject obj = stsc.getRecord();
        Schema.SObjectType objType = obj.getSObjectType();
        Schema.DescribeSobjectResult result = objType.getDescribe();
        keyPrefix = result.getKeyPrefix();
        system.debug('Variable keyPrefix: ' + keyPrefix);
    }
    
    public String getKeyPrefix() {
        return keyPrefix;
    }
    
    public void setKeyPrefix(String keyPrefix) {
        this.keyPrefix = keyPrefix;
    }
    
    public PageReference redirect() {
        Profile p = [SELECT Name FROM Profile WHERE Id = :UserInfo.getProfileId()];
        system.debug('Profile Name: ' + p.Name);
        
        String tabURL = '/' + keyPrefix + '/o';
        system.debug('Variable tabURL: ' + tabURL);
        
        if('Customer Portal'.equals(p.Name)) {
            return null;
        } else {
            PageReference pageRef = new PageReference(tabURL);
            pageRef.setRedirect(true);
            return pageRef;
        }
    }
}

 Any thoughts would be greatly appreciated!

Best Answer chosen by Admin (Salesforce Developers) 
bdardinbdardin

I ended up opening a case with Salesforce about it, and it turns out this documentation is COMPLETELY WRONG - you cannot override tabs with standard list controllers. Hopefully they remove this page pronto so it doesn't mislead any other poor soul out there!

All Answers

firechimpfirechimp

Hi bdardin,

Overriding the standard set controller will let you add your own button to the list view page.

 

Inorder to have a tab, just remove the current tab from the app and create a new tab that points to your visualforce page (then add this new tab to your app instead).

 

Hope this helps

bdardinbdardin

The documentation here says that I can override an object's tab with a page using the standard set controller. I shouldn't have to create a custom tab when I should be able to just override the tab. My question is why my page isn't showing up in the drop down even though I am using a standard set controller.

 

Thank you for the suggestion though, I may have to resort to that since Salesforce is refusing to work as it should. :)

bdardinbdardin

I ended up opening a case with Salesforce about it, and it turns out this documentation is COMPLETELY WRONG - you cannot override tabs with standard list controllers. Hopefully they remove this page pronto so it doesn't mislead any other poor soul out there!

This was selected as the best answer