EntitySubscription

Represents a subscription for a user following a record or another user. This object is available in API version 34.0 and later.
A user can subscribe to a record or to another user. Changes to the record and updates from the users are displayed in the Chatter feed on the user's home page, which is a useful way to stay up-to-date with other users and with changes made to records in Salesforce. Feeds are available in API version 18.0 and later.

Supported Calls

create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve()

Fields

Field Details
NetworkId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort
Description
ID of the community that this file originated from. This field is available in API version 26.0 and later, if Salesforce Communities is enabled for your organization.
ParentId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Required. ID of the record or user which the user is following.
SubscriberId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Required. ID of the User who is following the record or user.

Usage

Consider this when following records and users:

When using query() with EntitySubscription,
  • Note the following SOQL restriction. No SOQL limit if logged-in user has “View All Data” permission. If not, specify a LIMIT clause of 1,000 records or fewer.
  • A query using a WHERE clause can only filter by fields on the EntitySubscription object.
  • If user sharing is enabled and the querying user is not an administrator, a SOQL query must be constrained either by the ParentId or SubscriberId. Otherwise, the query behavior at run time is undefined, meaning the result set can be incomplete or inconsistent from invocation to invocation. For an unconstrained query, the sharing check limits imposed on a non-adminstrative user are likely to be exceeded before the query completes, because access checks are run against both parent and subject, for each row of the result set. We recommend using the Chatter REST API to query EntitySubscription data instead of running a SOQL query.
  • Users without the “View All Data” permission
    • Need read access on the object associated with the ParentId field to see which users are following records for the object.
    • Can use an ORDER BY clause in a query only to order by fields on the EntitySubscription object. For example, if the subscription relates to an Account record, the query can ORDER BY ParentId, but it can’t ORDER BY Account.Name.
    • Don’t always get all matching subscriptions when running a query. For these users, a query evaluates visibility criteria on a maximum of 500 records to reduce the prospect of long-running queries. If a user runs a query to see the CEO's subscriptions, it might scan a large number of records. The query only returns matches within the first 500 records scanned. It is possible that there are more subscriptions that are visible to the user, but they are not returned. To mitigate this, we recommend using a WHERE clause, if possible, to reduce the scope of the query.

Sample—SOQL

The following SOQL query returns subscriptions for all the accounts that a subscriber is following that have more than 10 employees:

SELECT Id 
FROM EntitySubscription 
WHERE SubscriberId = '005U0000000Rg2CIAS'
AND ParentId IN (
  SELECT Id FROM Account
  WHERE NumberOfEmployees > 10
)
LIMIT 200

See Also