The article below explains the need for a trigger on the UserServicePresence sObject to enable proper synchronization between Omni-Channel presence statuses and Q-assign presence statuses.
The UserServicePresence sObject is a Salesforce object available as part of enabling Omni-channel in the Salesforce Org. Records of this sObject type are created by Omni-channel as part of managing agent presence.
Salesforce prevents records of this type being created outside Omni-channel control.
We require a trigger on the UserServicePresence sObject in order that we can update the user status within the Ortoo app to keep them in sync.
Write unit tests to perform the actions that fire the trigger and verify expected results. Ortoo will try to always adhere to Salesforce recommendations. However, where we are prevented from doing so, we will endeavor to provide an alternative.
In order to install Q-assign in Salesforce orgs that may or may not have Omni-Channel enabled we cannot reference the UserServicePresence sObject directly (i.e. in a trigger).
The UserServicePresence sObject is only present within the Salesforce Org when Omni-channel is enabled. If not enabled, the package would not install if it had any direct references.
trigger UserServicePresenceTrigger on UserServicePresence ( after delete, after insert, after update, before delete, before insert, before update )
{
new ortoo_qra.GlobalApi_v1().triggerHandler_v1();
}
Due to this limitation, we provide the Apex Trigger as source code (via Help Site) only. This Apex Trigger calls the following method: only:ortoo_qra.GlobalApi_v1().triggerHandler_v1()
As it is not possible to insert a UserServicePresence record, a test class would not be able to cause this trigger to fire and therefore test the code within it. However, we have added test class for GlobaApi_v1 class to our Q-assign managed package so that we can get maximum code coverage for this class.
If you have any questions, please don't hesitate to reach out to us at support@ortooapps.com.