Newer Version Available
closeAgentWork
Changes the status of a work item to “Closed” and removes it from the list of work
items in the Omni-Channel widget. Available in API versions 32.0 and later.
Syntax
1sforce.console.presence.closeAgentWork(workId:String, (optional) callback:function)Arguments
| Name | Type | Description |
|---|---|---|
| workId | String | The ID of the work item that’s closed. |
| callback | function | JavaScript method to call when the work item associated with the workId is closed. |
Sample Code–Visualforce
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<apex:page>
18 <apex:includeScript value="/support/console/34.0/integration.js"/>
19 <a href="#" onClick="testCloseWork();return false;">Close Engaged Work Item</a>
20 <script type="text/javascript">
21 function testCloseWork() {
22 //First get the ID of the engaged work item to close it
23 sforce.console.presence.getAgentWorks(function(result) {
24 if (result.success) {
25 var works = JSON.parse(result.works);
26 var work = works[0];
27 if (work.isEngaged) {
28 //Now that we have the engaged work item ID, we can close it
29 sforce.console.presence.closeAgentWork(work.workId,function(result) {
30 if (result.success) {
31 alert('Closed work successfully');
32 } else {
33 alert('Close work failed');
34 }
35 });
36 } else {
37 alert('The work item should be accepted first');
38 }
39 }
40 });
41 }
42 </script>
43</apex:page>