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.
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
1<apex:page >
2 <apex:includeScript value="/support/console/68.0/integration.js"/>
3 <a href="#" onClick="testSendCustomEvent();">Send Custom Event</a>
4
5 <script type="text/javascript">
6
7 function testSendCustomEvent() {
8 //Get the value for 'myChatKey'from the sforce.console.chat.getDetailsByPrimaryTabId() or other chat methods.
9 //These values are for example purposes only
10 var chatKey = 'myChatKey';
11 var type = 'myCustomEventType'
12 var data = 'myCustomEventData'
13 sforce.console.chat.sendCustomEvent(chatKey, type, data, sendCustomEventSuccess);
14 }
15
16 function sendCustomEventSuccess(result) {
17 //Report whether sending the custom event was successful
18 if (result.success == true) {
19 alert('The customEvent has been sent');
20 } else {
21 alert('Sending the customEvent was not successful');
22 }
23 };
24
25 </script>
26</apex:page>