この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

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

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>

応答

このメソッドは非同期であるため、コールバックメソッドのオブジェクトで応答を返します。応答オブジェクトには次のプロパティが含まれます。

名前 説明
success Boolean カスタムイベントが正常に送信された場合は true、カスタムイベントが正常に送信されなかった場合は false