getChatLog()
特定のチャットキーに関連付けられたチャットのチャットログを返します。API バージョン 29.0 以降で使用できます。
構文
1sforce.console.chat.getChatLog(chatKey:String, callback:Function)引数
| 名前 | 型 | 説明 |
|---|---|---|
| chatKey | String | チャットログを取得するチャットに関連付けられた chatKey。 |
| 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="testGetChatLog();">Get Chat Log</a>
20
21 <script type="text/javascript">
22
23 function testGetChatLog() {
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 sforce.console.chat.getChatLog(chatKey, getChatLogSuccess);
28 }
29
30 function getChatLogSuccess(result) {
31 //Report whether getting the chat log was succesful
32 if (result.success == true) {
33 chatLogMessage = result.messages[0].content;
34 alert('The first message in this chatLog is: ' + chatLogMessage);
35 } else {
36 alert('Getting the chat log was not successful');
37 }
38 };
39
40
41 </script>
42</apex:page>応答
このメソッドは非同期であるため、コールバックメソッドのオブジェクトで応答を返します。応答オブジェクトには次の項目が含まれます。
| 名前 | 型 | 説明 |
|---|---|---|
| customEvents | customEvent オブジェクトの配列 | チャット中に発生したカスタムイベントを��すカスタムイベントオブジェクトの配列。 |
| messages | message オブジェクトの配列 | チャットログのすべてのチャットメッセージを含むチャットメッセージオブジェクトの配列。 |
| success | Boolean | チャットログが正常に取得された場合は true、チャットログが正常に取得されなかった場合は false。 |
customEvent
customEvent オブジェクトには、チャットログの単一のイベントと次のプロパティが含まれます。
| プロパティ | 型 | 説明 |
|---|---|---|
| source | String | カスタムイベントを開始したユーザ (チャット訪問者またはエージェント)。 |
| type | String | 発生したカスタムイベントのタイプ。 |
| data | String | チャットに送信されたカスタムイベントのデータ。チャットウィンドウからこのイベントを送信するために使用された liveagent.chasitor.sendCustomEvent() メソッドの data 引数に対応します。 |
| timestamp | Date/Time | カスタムイベントの受信日時。 |