initFileTransfer()

Initiates the process of transferring a file from a customer to an agent. Available in API version 31.0 or later.

Syntax 

1sforce.console.chat.initFileTransfer(chatKey:String, entityId:String, (optional)callback:Function)

Arguments 

NameTypeDescription
chatKeyStringThe chat key for the chat the file is transferred from.
entityIdStringThe ID of the transcript object to attach the transferred file to.
callbackfunctionJavaScript method that is called when the method is completed.

Sample Code–Visualforce 

1<apex:page>
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <a href="#" onClick="testInitFileTransfer();return false;">Init file transfer</a> 
4
5    <script type="text/javascript">
6        function testInitFileTransfer() {
7            //Gets the value for 'myChatKey'from the getChatRequests() or onChatRequested() methods. 
8            //These values are for example purposes only.
9            var chatKey = 'myChatKey';  var entityId = 'myEntityId';
10            sforce.console.chat.initFileTransfer(chatKey, entityId, fileSuccess);
11        }
12        
13        function fileSuccess(result) {
14            //Reports whether initiating the file transfer was successful.
15            if (result.success == true) {
16                alert('Initiating file transfer was successful.');
17            } else {
18                alert('Initiating file transfer was not successful.');
19            }
20        };
21    </script>
22</apex:page>

Response 

This method is asynchronous so it returns its response in an object in a callback method. The response object contains the following properties:

NameTypeDescription
successBooleantrue if the request to transfer a file was sent successfully; false if the request wasn’t sent successfully. A value of true doesn’t necessarily mean that the file was successfully transferred to an agent. Rather, it indicates that the request to begin a file transfer was sent successfully.