Newer Version Available

This content describes an older version of this product. View Latest

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) callback:function)

Arguments

Name Type Description
workId String The ID of the work item that the agent declines.
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/34.0/integration.js"/>
3    <a href="#" onClick="testAcceptWork();return false;">Accept Assigned Work Item</a>
4
5    <script type="text/javascript">
6        function testAcceptWork() {
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                    if (!work.isEngaged) {
13                        //Now that we have the assigned work item ID, we can accept it
14                        sforce.console.presence.acceptAgentWork(work.workId, function(result) { 
15                            if (result.success) {
16                                alert('Accepted work successfully');
17                            } else {
18                                alert('Accept work failed');
19                            }
20                        });
21                    } else {
22                        alert('The work item has already been accepted');
23                    }
24                }
25            });
26        }
27    </script>
28</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.