Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

declineChat()

Declines a chat request. Available in API version 29.0 or later. This method isn't supported with Omni-Channel in API version 37.0 or later.

Syntax

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

Arguments

Name Type Description
chatKey String The chat key for the request you wish to decline.
callback function JavaScript method called upon completion of the method.

Sample Code–Visualforce

1<apex:page>
2                <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <a href="#" onClick="testDeclineChat();return false;">Decline Chat</a> 
4
5    <script type="text/javascript">
6        function testDeclineChat() {
7            //Get the value for 'myChatKey'from the getChatRequests() or onChatRequested() methods. 
8            //These values are for example purposes only
9            var chatKey = 'myChatKey';
10            sforce.console.chat.declineChat(chatKey, declineSuccess);
11        }
12    
13    
14        function declineSuccess(result) {
15            //Report whether declining the chat was succesful
16            if (result.success == true) {
17                alert('Declining the chat was successful');
18            } else {
19                alert('Declining the chat was not successful');
20            }
21        };
22    </script>
23</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:

Name Type Description
success Boolean true if declining the event was successful; false if declining the event wasn’t successful.