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. In addition to the standard methods for console events, there are a few events that are specific to Omni-Channel. These events apply to Salesforce Classic only.

Standard Console Events 

EventDescriptionPayload
sforce.console.ConsoleEvent.​OPEN_TABFired 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_TABFired 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_LOGOUTDelays 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

Omni-Channel Console Events 

EventDescriptionPayload
sforce.console.ConsoleEvent.​PRESENCE.LOGIN_SUCCESSFired when an Omni-Channel user logs into Omni-Channel successfully.
Available in API version 32.0 or later.
  • statusId—the ID of the agent’s current presence status.
sforce.console.ConsoleEvent.​PRESENCE.STATUS_CHANGEDFired when a user changes his or her presence status.
Available in API version 32.0 or later.
  • statusId—the ID of the agent’s current presence status.
  • channels—channelJSON string of channel objects.
  • statusName—the name of the agent’s current presence status.
  • statusApiName—the API name of the agent’s current presence status.
sforce.console.ConsoleEvent.​PRESENCE.LOGOUTFired when a user logs out of Salesforce.
Available in API version 32.0 or later.
None
sforce.console.ConsoleEvent.​PRESENCE.WORK_ASSIGNEDFired when a user is assigned a new work item.
Available in API version 32.0 or later.
  • workItemId—the ID of the object that’s routed through Omni-Channel. This object becomes a work assignment with a workId when it’s assigned to an agent.
  • workId—the ID of a work assignment that’s routed to an agent.
sforce.console.ConsoleEvent.​PRESENCE.WORK_ACCEPTEDFired when a user accepts a work assignment, or when a work assignment is automatically accepted.
Available in API version 32.0 or later.
  • workItemId—the ID of the object that’s routed through Omni-Channel. This object becomes a work assignment with a workId when it’s assigned to an agent.
  • workId—the ID of a work assignment that’s routed to an agent.
sforce.console.ConsoleEvent.​PRESENCE.WORK_DECLINEDFired when a user declines a work assignment.
Available in API version 32.0 or later.
  • workItemId—the ID of the object that’s routed through Omni-Channel. This object becomes a work assignment with a workId when it’s assigned to an agent.
  • workId—the ID of a work assignment that’s routed to an agent.
sforce.console.ConsoleEvent.​PRESENCE.WORK_CLOSEDFired when the status of an AgentWork object is changed to Closed.
Available in API version 32.0 or later.
  • workItemId—the ID of the object that’s routed through Omni-Channel. This object becomes a work assignment with a workId when it’s assigned to an agent.
  • workId—the ID of a work assignment that’s routed to an agent.
sforce.console.ConsoleEvent. PRESENCE.WORKLOAD_CHANGEDFired when an agent’s workload changes. This includes receiving new work items, declining work items, and closing items in the console. It’s also fired when there’s a change to an agent’s capacity or Presence Configuration or when the agent goes offline in the Omni-Channel widget.
  • ConfiguredCapacity—the configured capacity for the agent.
  • PreviousWorkload—the agent’s workload before the change.
  • NewWorkload—the agent’s new workload after the change.

channel 

The channel object contains the following properties:

NameTypeDescription
channelIdStringRetrieves the ID of a service channel that’s associated with a presence status.
developerNameStringRetrieves the developer name of the the service channel that’s associated with the channelId.

Methods for Console Events 

MethodDescription
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.