When I open a Case (or anything else) in the default Console pages, I get a tab with an icon and a meaningful tab name for free.

How do I get that same functionality when using sforce.console.openPrimaryTab? If that's not doable, is there another way to get that functionality? I'd prefer using JavaScript since I'm trying to open these from a fairly dynamic Custom Application Component.

  • I don't think you can. I couldn't find a way when I looked anyway. I copied them with screenshots and had to do some post-processing. Bit of a PITA. :( I'll post what I tried and why it was challenging if no one else has found a way.
    – Adrian Larson
    Commented Sep 6, 2016 at 22:14
  • Their icons use an image with a transparent background and set the background color using CSS. Given my inadequate graphical editing options, it was annoying to recreate and I just went with whatever seemed fastest. I hope someone did find something better.
    – Adrian Larson
    Commented Sep 6, 2016 at 22:34
  • Yes, I was able to get the images for icons I've placed on the page, but I'd like to tie that visually to the page itself. Can I just do a srcUp on a URLFOR? Commented Sep 7, 2016 at 13:57
  • I don't follow. You're trying to set the tab icon, or use it somewhere else?
    – Adrian Larson
    Commented Sep 7, 2016 at 14:00
  • This question is asking how to set the tab icon and name as if I opened the tab clicking in standard layout pages. Commented Sep 7, 2016 at 15:42

1 Answer 1


The console has some pretty funky icon handling which I recommend against trying to replicate or hook into, primarily for the sake of your own sanity.

My recommendation would be to save the icons you want to use as static resources and then use the setTabIcon() method of the toolkit after opening your tab. For example, I create a resource named myIcon that holds my icon then use code like this:

function setIcon(result) { 
    sforce.console.setTabIcon("{!URLFOR($Resource.myIcon)}", result.id);    

function openPrimaryTab() {
  sforce.console.openPrimaryTab(null,'http://www.example.com',true,'example', setIcon);

If you have multiple icons and need to pick based on some criteria, then you could add that logic into the apex controller and populate a variable to indicate which icon is needed, or use javascript to make the decision based on some client-side criteria if you prefer. You could use URLFOR to get the root directory for a zipped resource, then javascript to append the appropriate filename onto it in order to complete the path.

For setting the tab name, use method setTabTitle() in basically the same way. Add a call to this method in the callback from openPrimaryTab and name your tab whatever you want.


  • Thank you. I'm afraid this may be the best solution... It's disappointing because it requires my component to make an extra query for the object Name and is very fragile regarding the icons. I'd like to let admins be in charge of these things. Commented Sep 8, 2016 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .