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
ShamSham 

Query for recently Viewed Records by the user

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

HI,

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:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_recentlyviewed.htm

 

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.