onAgentStateChanged()
Registers a function to call when agents change their Chat status, such as from
Online to Away. Available in API version 29.0 or
later.
Syntax
sforce.console.chat.onAgentStateChanged(eventHandler:Function)
Arguments
Name | Type | Description |
---|---|---|
eventHandler | function | JavaScript method called when the agent's Chat status has changed. |
Sample Code–Visualforce
<apex:page>
<apex:includeScript value="/support/console/64.0/integration.js"/>
<script type="text/javascript">
var eventHandler = function (result) {
alert("Agent's State has Changed to: " + result.state);
};
sforce.console.chat.onAgentStateChanged(eventHandler);
</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 properties:
Name | Type | Description |
---|---|---|
state | String | String that represents the agent’s current Chat status—for example, Online, Away, or Offline. When an agent switches from Offline to Away, you may see two returned values (Online then Away) instead of one (Away). |
success | Boolean | true if firing event was successful; false if firing event wasn’t successful. |