1

I have a requirement to route cases based on case creation date instead of when the case enters the queue. I am planning on creating a trigger on pendingservicerouting before insert to update CustomRequestedDateTime. Any help is appreciated on how this requirement can be achieved for queue based routing

https://developer.salesforce.com/docs/atlas.en-us.omni_channel_dev.meta/omni_channel_dev/sforce_api_objects_pendingservicerouting.htm

When you use PendingServiceRouting objects for queue-based routing, the PendingServiceRouting objects don’t invoke triggers before or after insert, or any action (trigger, workflow rule, validation) that could interfere with the creation of the PendingServiceRouting object.

0

The trigger on the PendingServiceRouting object as documentation saying will not be invoked. You would need to create a Trigger or a Flow on a Case object to trigger, you can use either before or after update. Then query PendingServiceRouting where the WorkItemId equals triggered case Id. After that you would modify the CustomRequestedDateTime to be Case CreatedDate and save the record.

Something like below:

  List<PendingServiceRouting> lstPendingServiceRouting = new List<PendingServiceRouting>();
        lstPendingServiceRouting = [SELECT Id, CustomRequestedDatetime, WorkItemId FROM PendingServiceRouting Where WorkItemId IN :caseIds AND CustomRequestedDatetime = null];
        for(PendingServiceRouting w : lstPendingServiceRouting) {     
            w.CustomRequestedDatetime = mapOfCaseIdToCase.get(w.WorkItemId).CreatedDate;
            lstPendingWorkItems.add(w);
        }

        Database.SaveResult[] saveRes = Database.update(lstPendingWorkItems, false);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.