Using acceptAgentWork console integration toolkit method in PRESENCE.WORK_ASSIGNED handler can lead to ghost work items in widget
Last updated 2022-02-10 ·Reference W-5080550 ·Reported By 7 users
Summary
Using acceptAgentWork console integration toolkit method in PRESENCE.WORK_ASSIGNED handler can lead to ghost work items in widget.
If custom VF code uses the console integration toolkit to accept Omni work as soon as it's assigned (via a PRESENCE.WORK_ASSIGNED handler calling acceptAgentWork), a race condition exists where the work is accepted, but the work item remains in the widget and can't be Accepted or Declined. It will remain there until going offline. This appears to be a race condition that occurs because AcceptWork is called programmatically before the widget is able to remove the work item from the display.
Repro
1. Set up an org with Omni Channel
2. Configure it to deliver work like Cases to a test user
3. Create a VF page and custom console component with this content:
<apex:page >
<apex:includeScript value="/support/console/42.0/integration.js"/>
<script>
var omniAssignedHandler = function(result){
console.log('omniAssignedHandler');
if (result){
sforce.console.presence.acceptAgentWork(
result.workId,
function(result) {
if (result.success) {
console.log('Wait for OPEN_TAB handler');
} else {
console.log('Err: omniAssignedHandler - acceptAgentWork err');
}
}
);
} else {
console.log('Err: omniAssignedHandler - Handler err');
}
};
sforce.console.addEventListener(
sforce.console.ConsoleEvent.PRESENCE.WORK_ASSIGNED,
omniAssignedHandler
);
</script>
</apex:page>
4. Add the custom console component to your console app
5. Go online with the agent for Cases (or whatever work item you configured Omni for).
6. The work should auto-accept due to the component.
7. Continue accepting and closing work until the issue repros (usually happens 1 out of 10 times).
Actual Result
------------------
The work remains in the widget despite being accepted.
Expected Result
------------------
The work should be removed from the widget when accepted.
Workaround
Either use the normal auto accept or add a delay in the code, like:
var delayAccept = function(result){
console.log("waiting a second or two");
setTimeout(omniAssignedHandler, 1000, result);
};
sforce.console.addEventListener(
sforce.console.ConsoleEvent.PRESENCE.WORK_ASSIGNED,
delayAccept
);
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.