focusSubtabByNameAndPrimaryTabName()

Focuses the browser on a subtab that is already open with the specified name and primary tab name. This method is only available in API version 22.0 or later.

Syntax

sforce.console.focusSubtabByNameAndPrimaryTabName(name:String, primaryTabName:String,(optional)callback:Function)

Arguments

Name Type Description
name string Name of the subtab to go to.
primaryTabName string Name of the primary tab in which the subtab opened.
callback function JavaScript method that’s called upon completion of the method.

Sample Code–Visualforce

<apex:page standardController="Case">

     <A HREF="#" onClick="testFocusSubtabByNameAndPrimaryTabName();return false">
         Click here to go to a subtab by name and primary tab name</A> 

    <apex:includeScript value="/support/console/63.0/integration.js"/>
    <script type="text/javascript">
        function testFocusSubtabByNameAndPrimaryTabName() {
            //Get the value for 'mySubtab' and 'myPrimaryTab' from the openSubtab method
            //These values are for example purposes only
            var subtabName = 'mySubtab';
            var primaryTabName = 'myPrimaryTab';
            sforce.console.focusSubtabByNameAndPrimaryTabName(subtabName, primaryTabName, focusSuccess);
        }
        
        var focusSuccess = function focusSuccess(result) {
            //Report whether going to the subtab was successful
            if (result.success == true) {
                alert('Going to the subtab was successful');
            } else {
                alert('Going to the subtab was not successful');
            }
        };
        
  </script>

</apex:page>

To see this example in action, click the custom link on a case. For more information, see Define Custom Buttons and Links in Salesforce Help.

Note

Response

This method is asynchronous, so it returns its response in an object in a callback method. The response object contains the following field:

Name Type Description
success boolean true if going to the subtab was successful; false if going to the subtab wasn't successful.