Newer Version Available
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.
- Create a Visualforce page. See the Visualforce Developer's Guide.
- Cut and paste the following sample code into your Visualforce page.
This code demonstrates various functions of the Salesforce Console Integration Toolkit:
1swfobject.registerObject("clippy.codeblock-0", "9"); 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17<apex:page standardController="Case"> 18 19 <apex:includeScript value="/support/console/20.0/integration.js"/> 20 <script type="text/javascript"> 21 function openPrimaryTab() { 22 sforce.console.openPrimaryTab(undefined, 23 'http://www.salesforce.com', true, 'salesforce'); 24 } 25 26 //The callback function that openSubtab will call once it's got the ID for its primary tab 27 var callOpenSubtab=function callOpenSubtab(result) { 28 sforce.console.openSubtab(result.id, 29 'http://www.yahoo.com', true, 'yahoo'); 30 }; 31 32 function openSubtab() { 33 sforce.console.getEnclosingPrimaryTabId(callOpenSubtab); 34 } 35 36 //Sets the title of the current tab to "SFDC" 37 function setTitle() { 38 sforce.console.setTabTitle('SFDC'); 39 } 40 41 //The callback function that closeTab will call once it's got the ID for its tab 42 var callCloseTab= function callCloseTab(result) { 43 sforce.console.closeTab(result.id); 44 } 45 46 function closeTab() { 47 sforce.console.getEnclosingTabId(callCloseTab); 48 } 49 </script> 50 51 <A HREF="#" onClick="openPrimaryTab();return false">Open A Primary Tab</A> 52 <p/><A HREF="#" onClick="openSubtab();return false">Open A Subtab</A> 53 <p/><A HREF="#" onClick="setTitle();return false">Set Title to SFDC</A> 54 <p/><A HREF="#" onClick="closeTab();return false">Close This Tab</A> 55 56</apex:page> 57
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
