• No results found

Methods for Navigation Tabs

A Salesforce console displays a navigation tab from which users can select objects to view lists or home pages. Administrators choose the objects that users can access from a navigation tab. For more information, see “Salesforce Console Navigation Tab” and “Create a Salesforce Console App” in the online help.

IN THIS SECTION:

focusNavigationTab()

Focuses the browser on the navigation tab. This method is only available in API version 31.0 or later.

getNavigationTabs()

Returns all of the objects in the navigation tab. This method is only available in API version 31.0 or later.

getSelectedNavigationTab()

Returns the selected object in the navigation tab. This method is only available in API version 31.0 or later.

refreshNavigationTab()

Refreshes the selected navigation tab. This method is only available in API version 31.0 or later.

setSelectedNavigationTab()

Sets the navigation tab with a specific ID or URL. This method is only available in API version 31.0 or later.

focusNavigationTab()

Focuses the browser on the navigation tab. This method is only available in API version 31.0 or later.

Syntax

sforce.console.focusNavigationTab((optional)callback:Function)

Arguments

Description Type

Name

JavaScript method that’s called upon completion of the method.

function callback

Sample Code–Visualforce

<apex:page>

<apex:includeScript value="/support/console/31.0/integration.js"/>

<script type="text/javascript">

var callback = function (result) {}

alert('success');

} else{

alert('Something is wrong.');

} };

sforce.console.focusNavigationTab(callback);

</script>

</apex:page>

Response

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

Description Type

Name

true if returning the object IDs was successful; false otherwise.

boolean success

getNavigationTabs()

Returns all of the objects in the navigation tab. This method is only available in API version 31.0 or later.

Syntax

sforce.console.getNavigationTabs((optional)callback:Function)

Arguments

Description Type

Name

JavaScript method that’s called upon completion of the method.

function callback

Sample Code–Visualforce

<apex:page>

<apex:includeScript value="/support/console/31.0/integration.js"/>

<script type="text/javascript">

var callback = function (result) { var id;

if (result.success) {

var tempItem = JSON.parse(result.items);

for (var i = 0, len = tempItem.length; i < len; i++) {

alert('Label:'+tempItem[i].label+'listViewURl:'+tempItem[i].listViewUrl+'navTabid:'

getNavigationTabs() Methods for Navigation Tabs

+tempItem[i].navigationTabId+'Selected ' +tempItem[i].selected);

}

} else {

alert('something is wrong!');

} };

sforce.console.getNavigationTabs(callback);

</script>

</apex:page>

Response

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

Description Type

Name

The IDs of objects in the navigation tab.

object menuItems

true if returning the IDs of objects in the navigation tab was successful, false otherwise.

boolean success

getSelectedNavigationTab()

Returns the selected object in the navigation tab. This method is only available in API version 31.0 or later.

Syntax

sforce.console.getSelectedNavigationTab((optional)callback:Function)

Arguments

Description Type

Name

JavaScript method that’s called upon completion of the method.

function callback

Sample Code–Visualforce

<apex:page>

<apex:includeScript value="/support/console/31.0/integration.js"/>

<script type="text/javascript">

var callback = function (result) {}

if (result.success) {

alert('the navigation tab id is ' + result.navigationTabId + ' and navigation url is ' + result.listViewUrl);

getSelectedNavigationTab() Methods for Navigation Tabs

} else {

alert('something is wrong!');

} };

sforce.console.getSelectedNavigationTab(callback);

</script>

</apex:page>

Response

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

Description Type

Name

The object ID of the selected object.

string navigationTabId

The list view URL of the selected object.

object listViewUrl

The label of the selected object.

object label

true if returning the selected field of the object was successful, false otherwise.

boolean selected

true if returning the object IDs was successful, false otherwise.

boolean success

refreshNavigationTab()

Refreshes the selected navigation tab. This method is only available in API version 31.0 or later.

Syntax

sforce.console.refreshNavigationTab((optional)callback:Function)

Arguments

Description Type

Name

JavaScript method that’s called upon completion of the method.

function callback

Sample Code–Visualforce

<apex:page>

<apex:includeScript value="/support/console/31.0/integration.js"/>

<script type="text/javascript">

var callback = function (result) {}

if(result.success){

refreshNavigationTab() Methods for Navigation Tabs

alert('success');

} else{

alert('Something is wrong.');

} };

sforce.console.refreshNavigationTab(callback);

</script>

</apex:page>

Response

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

Description Type

Name

true if refreshing the navigation tab was successful, false otherwise.

boolean success

setSelectedNavigationTab()

Sets the navigation tab with a specific ID or URL. This method is only available in API version 31.0 or later.

Syntax

sforce.console.setSelectedNavigationTab((optional)callback, navigatorTabId:(optional)string, url:(optional)string)

Arguments

Description Type

Name

JavaScript method that’s called upon completion of the method.

function callback

The ID of the navigation tab to be selected.

string navigatorTabId

The URL of the navigation tab to be selected.

string url

Sample Code–Visualforce

<apex:page>

<apex:includeScript value="/support/console/31.0/integration.js"/>

<script type="text/javascript">

var callback = function (result) {}

if (result.success) { alert('Successful');

setSelectedNavigationTab() Methods for Navigation Tabs

alert('something is wrong!');

} };

sforce.console.setSelectedNavigationTab(callback,'nav-tab-4');

</script>

</apex:page>

Response

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

Description Type

Name

true if setting the navigation tab with a specific ID or URL was successful, false otherwise.

boolean success

setSelectedNavigationTab() Methods for Navigation Tabs

CHAPTER 5 Methods for Computer-Telephony