Print this page

Lightning Experience: Overriding a tab and redirecting it to the overview page from Aloha will cause an unlimited loop and the page won't load

Knowledge Article Number 000231244
Description

Overriding a tab and redirecting it to the list view page from Aloha will cause an unlimited loop and the page won't load. 

Using Opportunities as an example: 

/006 is the opportunity list view page. The default landing for the Opportunity Tab in Aloha Classic is the Opportunity Overview page ending in /006/o. The default landing page for the Opportunity Tab in Lightning is the Opportunity list view - so this override doesn't work. An infinite loop is caused because the VF override is pointing to the list view page from the list view page in Lightning. The same issue actually occurs in Aloha Classic if a redirect points to the same page.

This can be reproduced/tested by doing the following:

Override Opportunity tab with the following VF page. 


<apex:page standardController="Opportunity" extensions="test" recordSetVar="opportunities" action="{!init}"> 
</apex:page> 

Then Create a test apex class with the following code for redirection. 
public class test { 
public test(ApexPages.StandardSetController controller) { 




public test(ApexPages.StandardController controller) { 



public PageReference init(){ 
String url='/006'; 
PageReference pr = new PageReference(url); 
pr.setRedirect(true); 
return pr; 



Switch to Lightning, click on "Opportunity" tab. 

Notice the page won't load.

 

 
Resolution The workaround for this currently is to only redirect to the List View page in Aloha Classic, not Lightning:

In Apex, only redirect to list view page in Aloha.

    public PageReference init(){
        if(UserInfo.getUiTheme() !='Theme3'){ //Aloha, redirect to list view page
            String url='/006';
            PageReference pr = new PageReference(url);
            pr.setRedirect(true);
            return pr;
        }else {//Not Aloha, redirect to any page that's not /006
            String url='/001';
            PageReference pr = new PageReference(url);
            pr.setRedirect(true);
            return pr;        
        }
   }




promote demote