I've custom console component(simple VF page) created for console app. I can grab the case id based on the tab selection but its not working for the very first time the page loads. When I select the tab then it works fine. What's missing here to get the selected tab during initial load ?


<apex:page standardcontroller="case" extensions="LoginIDInformation" >
    <apex:includeScript value="/support/console/31.0/integration.js"/>    
    <script type="text/javascript">
    var onFocusedSubtabCallback = function (result) {
            var entityId = result.objectId;
            if (entityId.substr(0,3) === '500') {

    var eventHandler = function (result) {
         var entityId = result.objectId;
            if (entityId.substr(0,3) === '500') {


<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection columns="1" >

            <apex:actionFunction action="{!updateCaseinfo}" name="updateCaseinfo" reRender="updateable">
                <apex:param name="newCaseId" assignTo="{!caseId}" value=""/>

            <apex:outputPanel id="updateable">
                <center><apex:commandButton value="Refresh" action="{!updateCaseinfo}"/>
                Selected Case: {!caseid}
                <apex:pageMessages ></apex:pagemessages>        



Controller :

public class LoginIDInformation{

public String caseId {                                            
        get {
            if(caseId == null) {
                caseId = ApexPages.currentPage().getParameters().get('id');
            return caseId;
 public case mycase{get;set;}

 public void updateCaseInfo() {                                

 if (caseId==null){
 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'No Case Found'));

 public LoginIDInformation(ApexPages.StandardController controller) {


2 Answers 2


You want getFocusedSubtabObjectId.

sforce.console.getFocusedSubtabObjectId(new function (result) {

On a side note, why reinvent the wheel? Just grab the caseId from your controller.

public with sharing class MyExtension
    public Id caseId { get; private set; }
    public MyExtension(ApexPages.StandardController controller)
        caseId = controller.getId();

I had the same problem and it took me awhile to figure out. There are not example of Custom console components.

Visualforce page: In this example you have two ways of passing the ID to the controller to then build your code since the normal way to get the parameters does not work (ApexPages.currentPage().getParameters().get('id');) This is due to the fact that tab are encapsulated like in a iframe. Also keep in mind that since the console does not behave the same as a regular Visualforce page and the extension controller is not getting information from your current object you can't populate the data. For that reason, you would need to build the controller.

VF page:

<apex:page standardController="Case" extensions="CaseConsoleControllerExt"> <apex:includeScript value="/support/console/42.0/integration.js"/> <script type="text/javascript"> if(sforce.console){ function GetPrimaryTabObjectId() { sforce.console.getFocusedPrimaryTabObjectId(showObjectId); } var showObjectId = function showObjectId(result) { //Display the object ID assignVar(result.id); alert('Object ID: '+result.id); } sforce.console.onCustomConsoleComponentButtonClicked(GetPrimaryTabObjectId); } </script> <apex:pageMessages /> <apex:form > <apex:pageBlock title="To Update SoldTo in Case inorder to get DIG" > <apex:pageBlockSection columns="1"> <apex:inputField value="{!case.status}" /> //No populating current case value. To be resolved </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Update"/> </apex:pageBlockButtons> <apex:actionFunction name="assignVar" onComplete="alert('Action Completed')" action="{!returnVar}"> <apex:param name="cid" value="" assignTo="{!consoleId}"/> </apex:actionFunction> </apex:pageBlock> </apex:form> <a href="#" onClick="GetPrimaryTabObjectId();return false">Click here to get the object ID of the focused subtab</a> </apex:page>


public with sharing class CaseConsoleControllerExt { public Id consoleId { get; set;} public void returnVar() {// This is where you get the param sent from the VF page System.debug('consoleId ' + consoleId); } public CaseConsoleControllerExt(ApexPages.StandardController controller) { // Do thonthing here } }

If you like my answer, please select it as the best answer.

You must log in to answer this question.

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