sendCustomEvent()
特定のチャットキーを持つチャットのクライアント側のチャットウィンドウにカスタムイベントを送信します。API バージョン 29.0 以降で使用できます。
構文
1sforce.console.chat.sendCustomEvent(chatKey:String, type:String, data:String, callback:Function)引数
| 名前 | 型 | 説明 |
|---|---|---|
| chatKey | String | カスタムイベントを送信するチャットに関連付けられた chatKey。 |
| type | String | チャットウィンドウに送信するカスタムイベントの名前。 |
| data | String | カスタムイベントと共にチャットウィンドウに送信する追加データ。 |
| callback | function | メソッドの完了時にコールされる JavaScript メソッド。 |
サンプルコード – Visualforce
1<apex:page >
2 <apex:includeScript value="/support/console/29.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>