Average Wait Time in Salesforce Omni-Channel Supervisor using Apex

Average Wait Time in Salesforce Omni-Channel Supervisor using Apex

Sample Code:
Integer i = 0;
Long total = 0;
for ( LiveChatTranscript chat : [ SELECT Id, CreatedDate, RequestTime FROM LiveChatTranscript WHERE OwnerID = ’00G5f000000aT2F’ ] ){
    
    i += 1;
    total += ( system.now().getTime() – chat.RequestTime.getTime() );
    
}
Long seconds = total / ( i * 1000 );
System.debug( ‘Average is ‘ + ( seconds / 60 ) + ‘ minutes and ‘ + math.mod( seconds, 60 ) + ‘ Seconds’ );

Leave a Reply