acceptAgentWork

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

Syntax 

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

Arguments 

NameTypeDescription
workIdStringThe ID of the work item the agent accepts.
callbackfunctionJavaScript method to call when an agent accepts 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="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:

NameTypeDescription
successBooleantrue if accepting the work item was successful; false if accepting the work item wasn’t successful.