RecentlyViewed

Represents records or list views that the current user has recently viewed or referenced (by viewing a related record). List views are available in API version 29.0 and later.

Introduced in API version 25.0.

describeSObjects(), query(), update()

The RecentlyViewed object doesn’t support the Event, Task, Report, KnowledgeArticle, and Article objects.

The RecentlyViewed object supports only certain objects, and supports list views only for those supported objects. Supported objects have the fields LastReferencedDate and LastViewedDate.

RecentlyViewed records for users who are members of several communities can’t be retrieved automatically into a map via Apex. This is because records of a user with different networks can result in duplicate IDs that maps don’t support.

  • Type: string
  • Properties: Filter, Group, Nillable, Sort
  • Description: The alias on the record.
  • Type: email
  • Properties: Filter, Group, Nillable, Sort
  • Description: The email address on the record.
  • Type: string
  • Properties: Filter, Group, Nillable, Sort, Update
  • Description: The first name on the record. If the recently viewed record is a user, the value is the user’s first name.
  • Type: string
  • Properties: Filter, Group, Nillable, Sort, Update
  • Type: boolean
  • Properties: Defaulted on create, Filter, Group, Sort
  • Description: Indicates whether the recently viewed record is an active user (true) or not (false). This field contains a value only if the recently viewed record is a user.
  • Default value: false
  • Type: picklist
  • Properties: Group, Nillable, Restricted picklist, Sort
  • Introduced: API version 30.0
  • Description: The combined language and locale ISO code, which controls the language of the Recently Viewed.
  • Type: string
  • Properties: Filter, Group, Nillable, Sort, Update
  • Description: The last name on the record.
  • Type: string
  • Properties: Filter, Group, Nillable, Sort, Update
  • Type: string
  • Properties: Filter, Group, Nillable, Sort
  • Description: The name on the recently viewed record or list view. If the recently viewed record is a user, contact, or lead, the value is a concatenation of the firstname and lastname field values.
  • Type: string
  • Properties: Filter, Group, Nillable, Sort
  • Introduced: API version 39.0
  • Type: reference

  • Properties: Filter, Group, Nillable, Sort

  • Introduced: API version 27.0

  • Description:

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

    You can add a NetworkId only when creating a group. You can’t change or add a NetworkId for an existing group.

  • Relationship name: Network

  • Relationship type: relationship

  • Refers to: Network

  • Type: phone
  • Properties: Filter, Group, Nillable, Sort
  • Description: The phone number on the record.
  • Type: reference

  • Properties: Filter, Group, Nillable, Sort

  • Description:

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

    This field is a relationship field.

  • Relationship name: Profile

  • Relationship type: relationship

  • Refers to: Profile

  • Type: picklist
  • Properties: Filter, Group, Nillable, Sort, Update
  • Type: string
  • Properties: Filter, Group, Nillable, Sort, Update
  • Type: string
  • Properties: Update
  • Type: string
  • Properties: Filter, Group, Nillable, Sort
  • Description: If the recently viewed record is a user, this value is the title of the user; for example CFO or CEO.
  • Type: picklist
  • Properties: Filter, Group, Nillable, Restricted picklist, Sort
  • Description: The object type for this recently viewed record or list view. Valid values include any standard or custom objects that RecentlyViewed supports.
  • Type: reference

  • Properties: Filter, Group, Nillable, Sort

  • Description:

    The ID of the user role associated with this object.

    This field is a relationship field.

  • Relationship name: UserRole

  • Relationship type: relationship

  • Refers to: UserRole

This object provides a heterogeneous list of different object types. The list consists of recently viewed records, records that were recently referenced (a related record was viewed), or recently viewed list views. A record is considered viewed when the user sees the record details, but not when the user sees the record 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, use this object 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 and 200 list views. RecentlyViewed data is retained for 90 days, after which it’s removed on a periodic basis.

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

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

This query retrieves a list of all recently viewed contacts with contact-specific fields, such as the contact’s account name, and the custom website field. Records are ordered from most to least recent.