Service Cloud Console Hyperlinks

apostrophes problem
The Problem with Apostrophes in Hyperlinks
April 12, 2013

Service Cloud Console Hyperlinks

salesforce service cloud
Applies to: Lightning

The Service Cloud Console required links on Visualforce pages to be setup a little differently. In the Console, a traditional hyperlink doesn’t work. You first need to open a new tab then display the link in the new tab. Hopefully, the examples below will help you in setting up your Visualforce pages so they’ll work within the Console as well as standard Salesforce pages.

<br /><span style="font-size: 12px; line-height: 1.6;"><apex:page standardcontroller="Contract" extensions="ContractExtension"></apex:page></span></p>
<p><apex:includescript value="/support/console/22.0/integration.js"><br /><script type="text/javascript"><br /><br />function openTab(recid, recname) {<br /><br />if(!sforce.console.isInConsole())<br /><br />window.parent.location.replace('/'+recid);<br /><br />else<br /><br />sforce.console.getEnclosingPrimaryTabId(function(result) {<br /><br />callBackopenTab(result, recid, recname);<br /><br />});<br /><br />}</p><br /><p><span style="font-size: 12px; line-height: 1.6;">function callBackopenTab(result, recordid, recordname) {</span></p><br /><p>sforce.console.openSubtab(, '/'+recordid , true, recordname, null);<br /><br />}<br /><br /></script></apex:includescript></p>
<p><span style="font-size: 12px; line-height: 1.6;"><apex:form ></span></p>
<p><apex:actionfunction name="onSelect" action="{!checkBox}" rerender="jsSelected"><br /><apex:param name="sId" value=""><br /></apex:param></apex:actionfunction></p>

This piece of code simulates the look and feel of a related list’s Action column by showing a checkbox and Edit link.

<br /><apex:column headervalue="Action" style="width:90px"><br /><apex:inputcheckbox value="{!myCheckbox}" onclick="onSelect('{!sl.Id}')"> |<br /><a href="#" onclick="openTab('{!sl.Id}/e?retURL=/{!sl.AccountId}','{!sl.Name}'); return false" ><b>edit<="" b><="" a=""><br /></a></apex:inputcheckbox></apex:column><a href="#" onclick="openTab('{!sl.Id}/e?retURL=/{!sl.AccountId}','{!sl.Name}'); return false" ><b>edit<="" b><="" a=""><br />

Below is a sample call using a commandButton. The additional parameter “selected” is optional. In this sample it is using in conjunction with the checkbox you see in the second code sample below.

<br /><apex:outputpanel id="jsSelected"><br /><apex:commandbutton id="combo" value="my Visualforce Page" onclick="openTab('apex/myVisualPage?id={!Id}&selected={!selectedIds}','Tab Name Here'); return false"><br /></apex:commandbutton></apex:outputpanel><br />

my-visualforce-pageHere’s how this might look on the Visualforce page. The command Button sits above the page BlockTable that has the Action column functionality. As the user marks a checkbox, the “onSelect” apex:ActionFunction is called which passed the record’s Id to a class in the extension for processing.



Terry Miller
Terry Miller
Terry has spent over 20 years focused on business leadership and information technology. As an independent consultant, he enjoys working with a variety of customers to help them solve business problems using the Salesforce® platform. His ability to quickly identify bottlenecks and provide understandable solutions has gained him the trust of his customers. If you're looking for expert guidance on your next Salesforce® project, click here to contact Terry today.

Leave a Reply