• Vinod Jakore
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Saleforce Developer/Consultant

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello,

I'm trying to take advantage of the new CustomRequestedDatetime field on the PendingServiceRouting omni-channel object  to better prioritize our cases.  I made a trigger that would update that field, but for some reason it's not firing when a new PSR is created.  Even when the trigger is just this:
 
trigger Set_Custom_Requested_DateTime on PendingServiceRouting (before insert) {
    system.debug('Trigger fired');
}
Nothing shows in the debug log.  Here's a test case I was using to try to invoke and test the trigger:
 
@isTest
private class Set_Custom_Requested_DateTime_Test {

    static testMethod void myUnitTest() {
        Case cWithLOD = new Case();
        String subj1 = 'Test subject: ' + math.random();
        cWithLOD.Subject = subj1;
        Insert cWithLOD;
        // Find an omni-channel queue
        Group g = [SELECT ID FROM Group WHERE QueueRoutingConfigId != null LIMIT 1];
        cWithLOD = [SELECT Last_opened_date__c, ID, OwnerID FROM Case WHERE Subject = :subj1 LIMIT 1];            
        
        // Add case to that queue
        cWithLOD.OwnerId = g.ID;
        Update cWithLOD;
        PendingServiceRouting p = [SELECT ID, WorkItemID, CustomRequestedDateTime, CreatedDate FROM PendingServiceRouting WHERE WorkItemID = :cWithLOD.ID LIMIT 1];
        // Confirm that the trigger fired and the field changed
        System.assertEquals(p.CustomRequestedDateTime, cWithLOD.Last_opened_date__c, 'LOD didnt match');
    }
}
When running this test (or just manually creating cases and adding them to an omni-channel queue) the trigger never fires.

Thanks for your help!