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.

declineAgentWork

Declines a work item that’s assigned to an agent. Available in API versions 32.0 and later.

Syntax

1sforce.console.presence.declineAgentWork(workId:String, (optional) declineReason:String, (optional) callback:function)

Arguments

Name Type Description
workId String The ID of the work item that the agent declines.
declineReason String The provided reason for why the agent declined the work request.
callback function JavaScript method to call when an agent declines the work item associated with the workId.

Sample Code–Visualforce

1<apex:page >
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <a href="#" onClick="testDeclineWork();return false;">Decline Assigned Work Item</a>
4
5    <script type="text/javascript">
6        function testDeclineWork() {
7            //First, get the ID of the assigned work item to accept it
8            sforce.console.presence.getAgentWorks(function(result) {
9                if (result.success) {
10                    var works = JSON.parse(result.works);
11                    var work = works[0];
12                    sforce.console.presence.declineAgentWork(work.workId, function(result) { 
13                            if (result.success) {
14                                alert('Declined work successfully');
15                            } else {
16                                alert('Decline work failed');
17                            }
18                        });
19                     }
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 work item was successful; false if declining the work item wasn’t successful.