getChatLog()
特定のチャットキーに関連付けられたチャットのチャットログを返します。API バージョン 29.0 以降で使用できます。
構文
1sforce.console.chat.getChatLog(chatKey:String, callback:Function)引数
| 名前 | 型 | 説明 |
|---|---|---|
| chatKey | String | チャットログを取得するチャットに関連付けられた chatKey。 |
| callback | function | メソッドの完了時にコールされる JavaScript メソッド。 |
サンプルコード – Visualforce
1<apex:page >
2 <apex:includeScript value="/support/console/29.0/integration.js"/>
3 <a href="#" onClick="testGetChatLog();">Get Chat Log</a>
4
5 <script type="text/javascript">
6
7 function testGetChatLog() {
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 sforce.console.chat.getChatLog(chatKey, getChatLogSuccess);
12 }
13
14 function getChatLogSuccess(result) {
15 //Report whether getting the chat log was succesful
16 if (result.success == true) {
17 chatLogMessage = result.messages[0].content;
18 alert('The first message in this chatLog is: ' + chatLogMessage);
19 } else {
20 alert('Getting the chat log was not successful');
21 }
22 };
23
24
25 </script>
26</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 | カスタムイベントの受信日時。 |