Service Console app : Sidebar components are not displaying when opening a VF page and then redirecting from that VF page to a record in the same tab

Apex , VisualForce , Knowledge , Service Cloud Console

Last updated 2018-01-08 ·Reference W-1778743 ·Reported By 34 users

No Fix

Summary
Opening a VF page (from custom button, custom link, custom console component, the console integration toolkit methods, etc), and then redirecting from that VF page to a record will not display any added sidebars as the tab has already been created and we cannot include the sidebar components after that.

Repro
1. Create a console app ( Setup -> Apps -> Click on New and select console app option ) and add the case tab for that App. We have to select case records open As a subtab of AccountName(Account).
2. Create Apex controller class
3. Create VF page
4. Create custom button on Case object (setup -> case -> Buttons)
5. Add custom button to case page layout
6. Open case page lay out - > click on Custom components link
7. Under Subtab components -> Go to Left sidebar -> Select the style as "Tabs" and then Action type as "lookup " and select field as "Account Name ". You can give
the Label as "Account Details"( you can give any name) and then hit save.

VF page:
======
<apex:page controller="Subtabclose">
<apex:form id="theForm">
<apex:commandButton action="{!doFinish}" value="TestButton" />
</apex:form>
</apex:page>

Apex class:
=========
public class Subtabclose {
public String pageId;
public Subtabclose()
{ }
public Subtabclose(ApexPages.StandardController stdController) {}
public PageReference doFinish(){
pageId = ApexPages.currentPage().getParameters().get('id');
PageReference ReturnToRecord = new PageReference('/50046000001rvhc');
ReturnToRecord .setRedirect(true);
return ReturnToRecord ;
}}

Workaround
Need to execute something similar to the below code on that VF page where "landingPage" is the page to be redirected to as they have to use openSubTab or openPrimaryTab to repaint the current tab so that the sidebars will show.
---------------------------------------
sforce.console.getEnclosingPrimaryTabId(getPrimaryTabId);
function getPrimaryTabId(result) {
primaryTabId = result.id;
sforce.console.getEnclosingTabId(getSubTabId);
};

function getSubTabId(result) {
subTabId = result.id;
sforce.console.openSubtab(primaryTabId, landingPage, true, 'New Case', subTabId);
};

--------------------------------------
For above replication steps example here is the sample workaround:
VF page:
=======
<apex:page controller="Subtabclose">
<apex:form id="theForm">
<apex:commandButton action="{!doFinish}" value="TestButton" />
</apex:form>

</apex:page>

Apex class:
=========
public class Subtabclose {
public String pageId;
public Subtabclose()
{ }
public Subtabclose(ApexPages.StandardController stdController) {}

public PageReference doFinish(){

PageReference ReturnToRecord = Page.RedirectTestPage;
ReturnToRecord.getParameters().put('landingpage', “whatever parameter value you want to pass”);
ReturnToRecord .setRedirect(true);
return ReturnToRecord ;
}}

Redirected VF page: (PageName: RedirectTestPage)
========================================
For example the following VF page receives the final landing page URL in a query param called "landingpage". The code in the VF page redirects the user to that page:

<apex:page showHeader="false" sidebar="false">
<apex:includeScript value="/support/console/29.0/integration.js"/>
<script type="text/javascript">

// if not in console redirect user to landing page
if (!(sforce.console.isInConsole())) {
window.location.replace('{!$CurrentPage.parameters.landingPage}');
}

// override subtab with the landing page requested
sforce.console.getEnclosingPrimaryTabId(getPrimaryTabId);

function getPrimaryTabId(result) {
primaryTabId = result.id;
sforce.console.getEnclosingTabId(getSubTabId);
};

function getSubTabId(result) {
subTabId = result.id;
sforce.console.openSubtab(primaryTabId, '{!$CurrentPage.parameters.landingPage}', true,
'New Case', subTabId);
};
</script>
</apex:page>

Updates
Please notice that this is actually working as designed. You may use the workaround provided to solve this problem.

Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.