Print this page

Set tab title when creation a new record in console

Knowledge Article Number 000233134
Description User created a Visual force page and used it to fill some predefined value for a new case creation and after selecting the values it will redirect to standard edit case page layout for case creation .When you create a case initially it will show you Tab title as "External Page" and if you set the tab title with setTabTitle method then title will not change after case creation so it will show as "New Case" in place of case number after the case creation.To overcome this issue you can use openSubtab in visual force page . This is applicable for any other object also .

 
Resolution Page 
=============================================
<apex:page standardController="Case" extensions="consoleTab"  sidebar="true" showHeader="true" >
 <apex:form >   
        <!--First click this link to set the current subtab's title-->
        <P><B> Problem </B> </P>
        <A HREF="#" onClick="testSetTabTitle();return false">
             Click here to change this tab's title</A>         
        <br></br>    
        <!--This is the issue: Click on the below link and notice that the tab title remains the same-->
        <apex:commandLink value=" Create New Case" action="{!goToCaseEditPage}" />      
       <br></br>
    </apex:form>
    
       <P> <B>Solution</B> </P>
       <!--Issue is not happening if I use openSubTab.You can do this programmatically also but I am explicitly clicking the link to get the subtab id-->
        <A HREF="#" onClick="testGetFocusedSubtabId();return false">
            Get SubTabId</A> 
        <br></br>
        <A HREF="#" onClick="testOpenSubtab();return false">
            create new case</A>        
    
    <apex:includeScript value="/support/console/35.0/integration.js"/>
    <script type="text/javascript">
        var g_subId;
        function testGetFocusedSubtabId() {
            sforce.console.getFocusedSubtabId(showTabId);
        }
        var showTabId = function showTabId(result) {
                // Display the tab ID
            g_subId = result.id;
            alert('Done, now click on the below link.');
        };
        function testSetTabTitle() {
            //Set the current tab's title
            sforce.console.setTabTitle('My New Title');
        }
        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }
        
        var openSubtab = function openSubtab(result) {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , '/500/e?cas7=Escalated&cas11=Phone', true, '', g_subId, openSuccess, null);
        };
        
        var openSuccess = function openSuccess(result) {
            //Report whether we succeeded in opening the subtab
            if (result.success == true) {
                alert('subtab successfully opened');
            } else {
                alert('subtab cannot be opened');
            }
        };
    </script>
</apex:page>
=============================================

Extension 
============================================
public class consoleTab 
{
  public consoleTab (ApexPages.StandardController controller)
    { }
 // Returns the edit page of the case, pre-defaulted attributes are passed through the URL
        public pagereference goToCaseEditPage()
        {          
            // Create a new edit page for the Case 
            PageReference caseEditPage = new PageReference('/'+SObjectType.Case.getKeyPrefix()+'/e' );
            return caseEditPage;
        }       
}
==============================================

 




promote demote