Newer Version Available
sendCustomEvent()
Sends a custom event to the client-side chat window for a chat with a specific chat
key. Available in API version 29.0 or
later.
Syntax
1sforce.console.chat.sendCustomEvent(chatKey:String, type:String, data:String, callback:Function)Arguments
| Name | Type | Description |
|---|---|---|
| chatKey | String | The chatKey associated with the chat to which to send a custom event. |
| type | String | The name of the custom event you want to send to the chat window. |
| data | String | Additional data you want to send to the chat window along with the custom event. |
| callback | function | JavaScript method called upon completion of the method. |
Sample Code–Visualforce
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<apex:page >
18 <apex:includeScript value="/support/console/29.0/integration.js"/>
19 <a href="#" onClick="testSendCustomEvent();">Send Custom Event</a>
20
21 <script type="text/javascript">
22
23 function testSendCustomEvent() {
24 //Get the value for 'myChatKey'from the sforce.console.chat.getDetailsByPrimaryTabId() or other chat methods.
25 //These values are for example purposes only
26 var chatKey = 'myChatKey';
27 var type = 'myCustomEventType'
28 var data = 'myCustomEventData'
29 sforce.console.chat.sendCustomEvent(chatKey, type, data, sendCustomEventSuccess);
30 }
31
32 function sendCustomEventSuccess(result) {
33 //Report whether sending the custom event was successful
34 if (result.success == true) {
35 alert('The customEvent has been sent');
36 } else {
37 alert('Sending the customEvent was not successful');
38 }
39 };
40
41 </script>
42</apex:page>