function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

OMNI Channel - Trigger & control the owner change

Background of the issue:
We have just started exploring the option of using OMNI Channel for our service cloud CSR user. I have turned on omni channel settings in my Dev org. I have set up the routing and service channel configurations for omni channel for a custom object. In our org, for contacts we have custom sharing settings (On contact object, we have a restricted flag, if a contact is restricted, then only certain roles can see that contact). On the custom object record, we have a lookup to contact, with OMNI Channel when we assign the custom object record to a Queue, if that custom object record's contact is restricted then that Queue user is not supposed to accept that custom object record.

When the user clicks "Accept" in OMNI Channel, we wrote a trigger on the custom object record, to control the change of owner, however, OMNI Channel Agent's accept does not fire the trigger on the custom object for which the owner is getting changed.

I would like to undestand, why the trigger on the custom object record does not fire, when the owner is changed from Queue to a User, when the User clicks "Accept" through OMNI Channel.

Is there any way to write trigger on Agentwork object? Please advice..
The trigger on the custom object does NOT fire when Omni Channel assigns it.  That is by design.
Nicolás KacowiczNicolás Kacowicz
There's a WorkAround.
Whenever the Omnichannel assign a record to an Agent, an AgentWork record gets created.

You can create a Process Builder and then call an Apex method if you have custom logic that you want to execute. (