---
title: "Use the RecentlyViewed table"
url: "https://blog.beyondthecloud.dev/tips/use-the-recentlyviewed-table"
category: "SOQL"
published: "2024-03-06"
---

# Use the RecentlyViewed table

By running this simple query, you can get records that user recently viewed:

### Did you know you can query recently viewed records?

By running this simple query, you can get records that user recently viewed:

```sql
SELECT Id, Name
FROM RecentlyViewed
WHERE Type IN ('Account', 'Contact', 'User')
ORDER BY LastViewedDate DESC
```

Why it is useful?

Using this simple query, you can build custom Recently Viewed lists:

![Use the RecentlyViewed table — screenshot 2](https://blog.beyondthecloud.dev/tips/use-the-recentlyviewed-table/fig-2.webp)

Or use it as a search proposition in input components:

![Use the RecentlyViewed table — screenshot 3](https://blog.beyondthecloud.dev/tips/use-the-recentlyviewed-table/fig-3.webp)
