1. Create a Visualforce page with the below code.
Sample Visualforce page:
<apex:page standardController=”Case”>
<apex:includeScript value=”/support/console/39.0/integration.js”/>
<script type=”text/javascript”>
/* Opens Case’s Contact in primary tab */
function openPrimaryTab() {
sforce.console.openPrimaryTab(undefined,
‘{!$Site.BaseUrl}/{!Case.Contact.Id}’, true, ‘Contact’);
}
/* Opens Case’s Contact in sub tab */
var callOpenSubtab=function callOpenSubtab(result) {
sforce.console.openSubtab(result.id,
‘{!$Site.BaseUrl}/{!Case.Contact.Id}’, true, ‘Contact’);
};
function openSubtab() {
sforce.console.getEnclosingPrimaryTabId(callOpenSubtab);
}
//Sets the title of the current tab to “Example”
function setTitle() {
sforce.console.setTabTitle(‘Example’);
}
//The callback function that closeTab will call once it has the ID for its tab
var callCloseTab= function callCloseTab(result) {
sforce.console.closeTab(result.id);
}
function closeTab() {
sforce.console.getEnclosingTabId(callCloseTab);
}
</script>
<A HREF=”#” onClick=”openPrimaryTab();return false”>Open A Primary Tab</A>
<p/><A HREF=”#” onClick=”openSubtab();return false”>Open A Subtab</A>
<p/><A HREF=”#” onClick=”setTitle();return false”>Set Title to Example</A>
<p/><A HREF=”#” onClick=”closeTab();return false”>Close This Tab</A>
</apex:page>
2. Go to Buttons, Links, and Actions under Case.
2. Click “New Button or Link”.
3. Save it.
4. Add it to the Case page layout.
5. Open a Case record and Click the link.
Set Title to Example:
Open A Subtab:
Open A Primary Tab: