+ 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 :)
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