Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
showWhenOnline
Usage
Displays a particular element when the specified button, agent, or agent-with-fallback-button is online. Available in API versions 28.0 and later.
Syntax
For a button, userId is optional: void showWhenOnline(String buttonId, Object element, (optional) String userId)
For an agent, use userId instead of buttonId: void showWhenOnline(String userId, Object element)
For an agent with fallback-to-button, use both IDs (the element shows when either the agent or button is online): void showWhenOnline(String buttonId, Object element, String userId)
Parameters
| Name | Type | Description | Available Versions |
|---|---|---|---|
| buttonId | String | The ID of the chat button for which to display the specified element object when agents that are associated with the button are available to chat. | Available in API versions 28.0 and later |
| element | Object | The element to be displayed when the specified button is online. | Available in API versions 28.0 and later |
| userId | String | The ID of the agent to associate with the button. The element object is displayed when that agent is available. | Available in API versions 28.0 and later |
If you specify a button ID but not a user ID in your parameters, the element is displayed only if the button is online.
1liveagent.showWhenOnline('005xx000001Sv1m', document.getElementById('liveagent_button_toAgent_online'));1liveagent.showWhenOnline('573xx0000000006', document.getElementById('liveagent_button_online_573xx0000000006_USER1'), '005xx000001Sv1m');