---
schema_version: "1"
id: f6b8f4db634a1e6c99a819912e595a405e2199a9d43db48f6c3108f2f49c81df
title: RecentlyViewed
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_tooling/tooling_api_objects_recentlyviewed.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_recentlyviewed.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 43d795210612b10e7399c9c2fd286a964d83d8cf0678153d97ce205f96fad267
description: Represents metadata entities typically found in Setup such as page layout definitions, workflow rule definitions, and email templates that the current user has recently viewed.
---
# RecentlyViewed

Represents metadata entities typically found in Setup such as page layout definitions, workflow rule definitions, and email templates that the current user has recently viewed.

This object is available in the Tooling API version 33.0 and later.

## Supported SOAP Calls

query(), update(),

## Supported REST HTTP Methods

GET

## Special Usage Rules

The RecentlyViewed object supports the following metadata entities:

- Apex classes
- Apex triggers
- Approval processes
- Apps
- Custom report types
- Email templates
- Fields
- Objects
- Page layouts
- Permission sets
- Profiles
- Static resources
- Tabs
- Users
- Validation rules
- Visualforce pages
- Visualforce components
- Workflow email alerts
- Workflow field updates
- Workflow outbound messages
- Workflow rules
- Workflow tasks

## Fields

| Field | Details |
| --- | --- |
| Alias | 
Type

string

Properties

Filter, Group, Nillable, Sort

Description

The alias on the item.



 |
| Email | 

Type

email

Properties

Filter, Group, Nillable, Sort

Description

The email address on the item.



 |
| FirstName | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The first name on the item.



 |
| Id | 

Type

ID

Properties

Defaulted on create, Filter, Group, Sort

Description

The ID of the recently viewed item.



 |
| IsActive | 

Type

boolean

Properties

Defaulted on create, Filter, Group, Sort

Description

Indicates whether the recently viewed item is an active user (true) or not (false). This field contains a value only if the recently viewed item is a user.



 |
| LastName | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The last name on the item.



 |
| LastReferencedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort, Update

Description

The timestamp for when the current user last viewed an item related to this item.



 |
| LastViewedDate | 

Type

dateTimedateTime

Properties

Filter, Nillable, Sort, Update

Description

The timestamp for when the current user last viewed this item. If this value is null, this item might only have been referenced (see LastReferencedDate) and not viewed.



 |
| Name | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

If the recently viewed item is a user, this is the user’s name. Specifically, it’s the concatenation of the FirstName and LastName field values.



 |
| NetworkId | 

Type

reference

Properties

Filter, Group, Nillable, Sort

Description

The ID of the Experience Cloud site that this recently viewed item is part of. This field is available only if digital experiences is enabled in your org.





 |
| Phone | 

Type

phone

Properties

Filter, Group, Nillable, Sort

Description

The phone number on the item.



 |
| ProfileId | 

Type

reference

Properties

Filter, Group, Nillable, Sort

Description

If the recently viewed item is a user, this is the user’s profile ID.



 |
| RelatedObject | 

Type

picklist

Properties

Filter, Group, Nillable, Restricted picklist, Sort

Description

The object that the recently viewed item is related to. For example, if the recently viewed item is an Account Custom Field, then the related object will be Account. Not all recently viewed items will have a related object.



 |
| Title | 

Type

string

Properties

FilterGrouplable, Sort

Description

If the recently viewed item is a user, this is the user’s title. For example, CFO or CEO.



 |
| Type | 

Type

picklist

Properties

Filter Group NillableRestricted picklist Sort

Description

The sObject type for this recently viewed item.



 |
| UserRoleId | 

Type

reference

Properties

FilterGroupNillableSort

Description

The ID of the user role associated with this object.



 |

## Usage

This object provides a heterogeneous list of different metadata types and consists of recently viewed records. A record is considered viewed when the user sees the details associated with it, but not when the user sees it in a list with other records. Use this object to programmatically construct a list of recently viewed items specific to the current user, for example, on a custom user interface or for search auto-complete options. You can also retrieve a filtered list of records by object type (Type). The RecentlyViewed data is periodically truncated down to 200 records per object. RecentlyViewed data is retained for 90 days, after which it is removed on a periodic basis.

Use this query in your code to retrieve a list of all the records that were recently viewed. The results are ordered from most to least recent.

SELECT Id, Name
FROM RecentlyViewed
WHERE LastViewedDate !=null
ORDER BY LastViewedDate DESC 

Use this query to retrieve data that was either viewed or referenced, but only for a limited set of objects.

SELECT Id, Name
FROM RecentlyViewed 
WHERE Type IN ('CustomEntityDefinition', 'CustomFieldDefinition')
ORDER BY LastViewedDate DESC