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
Flint LockwoodFlint Lockwood 

Querying the UserServicePresence Object

Anyone have a good way to query the UserServicePresence object? This object creates multiple records per agent per day. I only need to query the most recent record. 
Amit Singh 1Amit Singh 1
Hello Flint,

Use below SOQL query .
Select Id, Capacity, Name, Isaway From UserServicePresence Order By LastModifiedDate desc
Hope this helps :)
Thanks!
Amit Singh
 
Flint LockwoodFlint Lockwood
This doesn't lessen the number of query rows
Ramon PereiraRamon Pereira
It might be interesting to you just the active records. This is reduced to the number of records.
 
SELECT Id, Name, User.Name, ServicePresenceStatus.MasterLabel, StatusStartDate, ConfiguredCapacity, StatusEndDate, IsAway, IdleDuration, AtCapacityDuration, AverageCapacity, IsCurrentState, StatusDuration FROM UserServicePresence Where StatusEndDate = null