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.

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().then(function(result) {
5            var works = JSON.parse(result.works);
6            var work = works[0];
7            omniAPI.closeAgentWork({workId: work.workId}).then(function(res) {
8                if (res) {
9                    console.log("Closed work successfully");
10                } else {
11                    console.log("Close work failed");
12                }
13            }).catch(function(error) {
14                console.log(error);
15            });
16        });        
17    }        
18})

Response

This method returns a promise that, upon success, resolves to true and is rejected on error.