Newer Version Available

This content describes an older version of this product. View Latest

Sample Visualforce Page Using the Salesforce Console Integration Toolkit

This example shows how to change the Salesforce console user interface using the Salesforce Console Integration Toolkit.
  1. Create a Visualforce page. See the Visualforce Developer's Guide.
  2. Cut and paste the following sample code into your Visualforce page.

    This code demonstrates various functions of the Salesforce Console Integration Toolkit:

    1<apex:page standardController="Case">
    2
    3   <apex:includeScript value="/support/console/20.0/integration.js"/>
    4   <script type="text/javascript">
    5        function openPrimaryTab() {
    6            sforce.console.openPrimaryTab(undefined, 
    7               'http://www.salesforce.com', true, 'salesforce');
    8        }
    9        
    10        //The callback function that openSubtab will call once it's got the ID for its primary tab
    11        var callOpenSubtab=function callOpenSubtab(result) {
    12            sforce.console.openSubtab(result.id, 
    13               'http://www.yahoo.com', true, 'yahoo');
    14        };
    15        
    16        function openSubtab() {
    17            sforce.console.getEnclosingPrimaryTabId(callOpenSubtab);
    18        }
    19
    20        //Sets the title of the current tab to "SFDC"
    21        function setTitle() {
    22            sforce.console.setTabTitle('SFDC');
    23        }
    24        
    25        //The callback function that closeTab will call once it's got the ID for its tab
    26        var callCloseTab= function callCloseTab(result) {
    27            sforce.console.closeTab(result.id);
    28        }
    29        
    30        function closeTab() {
    31            sforce.console.getEnclosingTabId(callCloseTab);
    32        }
    33  </script>
    34
    35   <A HREF="#" onClick="openPrimaryTab();return false">Open A Primary Tab</A> 
    36   <p/><A HREF="#" onClick="openSubtab();return false">Open A Subtab</A> 
    37   <p/><A HREF="#" onClick="setTitle();return false">Set Title to SFDC</A> 
    38   <p/><A HREF="#" onClick="closeTab();return false">Close This Tab</A> 
    39
    40</apex:page>
After you create the above Visualforce page and add it as a custom link on cases, this page displays after you navigate to a case and click the link:
Output of Sample Visualforce Page
output of sample visualforce page with various functions of the service cloud console integration toolkit