getAgentWorks for Lightning Experience

Returns a list of work items that are assigned to an agent and open in the agent’s workspace.

Sample Code 

Component code:

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

Controller code:

1({
2    getAgentWorks: function(cmp, evt, hlp) {
3        var omniAPI = cmp.find("omniToolkit");
4        omniAPI.getAgentWorks().then(function(result) {
5            var works = JSON.parse(result.works);
6            console.log('First Agent Work ID is: ' +  works[0].workId);
7            console.log('Assigned Entity Id of the first Agent Work is: ' + works[0].workItemId);
8            console.log('Is first Agent Work Engaged: ' + works[0].isEngaged);
9        }).catch(function(error) {
10            console.log(error);
11        });
12    }
13})

Response 

This method returns a promise that, upon success, resolves to an array of work objects, containing the following fields.

NameTypeDescription
workItemIdStringThe ID of the object that’s routed through Omni-Channel. This object becomes a work assignment with a workId when it’s assigned to an agent.
workIdStringThe ID of a work assignment that’s routed to an agent.
isEngagedBooleanIndicates whether an agent is working on a work item that’s been assigned to them (true) or not (false).