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.

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

1<apex:page>
2     <apex:includeScript value="/support/console/68.0/integration.js"/>
3     <a href="#" onClick="testCloseWork();return false;">Close Engaged Work Item</a>
4     <script type="text/javascript">
5         function testCloseWork() {
6             //First get the ID of the engaged work item to close it
7             sforce.console.presence.getAgentWorks(function(result) {
8                 if (result.success) {
9                     var works = JSON.parse(result.works);
10                     var work = works[0];
11                     if (work.isEngaged) {
12                         //Now that we have the engaged work item ID, we can close it 
13                         sforce.console.presence.closeAgentWork(work.workId,function(result) {
14                             if (result.success) {
15                                  alert('Closed work successfully');
16                             } else {
17                                 alert('Close work failed');
18                             }
19                         });
20                     } else {
21                         alert('The work item should be accepted first');
22                     }
23                 }
24             });
25         }
26     </script>
27</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 closing the work item was successful; false if closing the work item wasn’t successful.