0

I'm trying to remove the workItem from my Omnichannel whenever an End User or an Agent End the chat. For this, I'm writing this Lightning Component. If I have 3 workItems and the 2nd Agent end the chat then it is removing the 1st and 2nd workitems in this list.But I want to remove only the second one.

Below Is my Code.

Component:

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

Controller.Js

({
    closeWork: function(cmp, evt, hlp) {
        var omniAPI = cmp.find("omniToolkit");
        omniAPI.getAgentWorks().then(function(result) {
            var works = JSON.parse(result.works);
            var work = works[0];
            omniAPI.closeAgentWork({workId: work.workId}).then(function(res) {
                if (res) {
                    console.log("Closed work successfully");
                } else {
                    console.log("Close work failed");
                }
            }).catch(function(error) {
                console.log(error);
            });
        });        
    }        
})

I'm new to Lightning. Please help me with this.

Thanks In Advance,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.