Newer Version Available

This content describes an older version of this product. View Latest

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 community that this group is part of. This field is available only if Salesforce Communities is enabled in your organization.

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.

1SELECT Id, Name
2FROM RecentlyViewed
3WHERE LastViewedDate !=null
4ORDER BY LastViewedDate DESC

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

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