getAgentWorks

Returns a list of work items that are currently assigned to an agent and open in the agent’s workspace. Available in API versions 32.0 and later.

Syntax 

1sforce.console.presence.getAgentWorks(callback:function)

Arguments 

NameTypeDescription
callbackfunctionJavaScript method to call when the list of an agent’s work items is retrieved.

Sample Code–Visualforce 

1<apex:page>
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <a href="#" onClick="testGetWorks();return false;">Get Agent’s Current Work Items</a>
4    
5    <script type="text/javascript">
6        function testGetWorks() {
7            //These values are for example purposes only.
8            sforce.console.presence.getAgentWorks(function(result) {
9                if (result.success) {
10                    alert('Get work items successful');
11                    var works = JSON.parse(result.works);
12                    alert('First Agent Work ID is: ' +  works[0].workId);
13                    alert('Assigned Entity Id of the first Agent Work is: ' + works[0].workItemId);
14                    alert('Is first Agent Work Engaged: ' + works[0].isEngaged);
15                } else {
16                    alert('Get work items failed');
17                }
18            });
19        }
20    </script>
21</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:

NameTypeDescription
successBooleantrue if retrieving the agent’s work items was successful; false if retrieving the agent’s work items wasn’t successful.
worksJSON string of work objectsA JSON string of work objects that represents the work items assigned to the agent that are open in the agent’s workspace.

work 

The work object contains the following properties:

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).