Newer Version Available

This content describes an older version of this product. View Latest

Methods for Console Events

JavaScript can be executed when certain types of events occur in a console, such as when a user closes a tab. The following standard events are supported:
Event Description Payload
sforce.console.ConsoleEvent.OPEN_TAB Fired when a primary tab or subtab is opened. Available in API version 30.0 or later.
  • id — The ID of the opened tab.
  • objectId — The object ID of the opened tab, if available.
sforce.console.ConsoleEvent.CLOSE_TAB Fired when a primary tab or subtab with a specified ID in the additionalParams argument is closed. Or, fired when a primary tab or subtab with no specified ID is closed. Available in API version 30.0 or later.
  • id — The ID of the closed tab.
  • objectID — The object ID of the closed tab, if available.
sforce.console.ConsoleEvent.CONSOLE_LOGOUT Delays the execution of logging out of a console when a user clicks Logout. When Logout is clicked:
  1. An overlay appears, which tells a user that logout is in progress.
  2. Callbacks are executed that have been registered by using sforce.console.ConsoleEvent.CONSOLE_LOGOUT.
  3. Console logout logic is executed.

If the callback contains synchronous blocking code, the console logout code isn’t executed until the blocking code is executed. As a best practice, avoid synchronous blocking code or long code execution during logout.

Available in API version 31.0 or later.

None

You can use the following methods for console events:
Method Description
addEventListener() Adds a listener for a custom event type or a standard event type when the event is fired. This method adds a listener for custom event types in API version 25.0 or later; it adds a listener for standard event types in API version 30.0 or later.
fireEvent() Fires a custom event. This method is only available in API version 25.0 or later.
removeEventListener() Removes a listener for a custom event type or a standard event type. This method removes a listener for custom event types in API version 25.0 or later; it removes a listener for standard event types in API version 30.0 or later.