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

Query for recently Viewed Records by the user

In Apex,it is possible to query the Recently viewed records by the user ?
A possible alternative is to query by the LastModifiedDate field to query for the recently modified records.


You can Use the below query:

List<RecentlyViewed> accList = [SELECT Id, Name FROM RecentlyViewed WHERE LastViewedDate !=null ORDER BY LastViewedDate DESC ];


And please go through the below Link:


You can also retrieve records that were either viewed or referenced, but only for a limited set of objects.


If this post helps you please give Kudos.