Newer Version Available

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

closeAgentWork for Lightning Experience

Changes the status of a work item to “Closed” and removes it from the list of work items in the Omni-Channel utility.

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

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2    <lightning:omniToolkitAPI aura:id="omniToolkit" />
3    <lightning:button label="Close" onclick="{! c.closeWork }" /> 
4</aura:component>

Controller code:

1({
2    closeWork: function(cmp, evt, hlp) {
3        var omniAPI = cmp.find("omniToolkit");
4        omniAPI.getAgentWorks({
5            callback: function(result) {
6                var works = JSON.parse(result.works);
7                var work = works[0];
8                omniAPI.closeAgentWork({
9                    workId: work.workId,
10                    callback: function(result2) {
11                        if (result2.success) {
12                            console.log("Closed work successfully");
13                        } else {
14                            console.log("Close work failed");
15                        }
16                    }
17                });
18            }
19        });
20    }        
21})

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.