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
vishesh91vishesh91 

find userId which has waited most since their last case assignment

hi all

I want to find userId which has waited most since their last case assignment,how to do it in apex.

Any help will be much appreciated

sfdcfoxsfdcfox

The Round Robin Assignment article in the standard Help might offer you a reasonable solution. You might consider it if only because statistically speaking, Round Robin, even if it misses (say, if not every record is assigned because of business logic), the distribution of cases would be relatively even. If you absolutely need a pecking order, I would say you'd probably want to run some sort of aggregate query against CaseHistory, grouping by user and MIN(Date), and filtering to find entries that are ownerAssignment entries.