Newer Version Available
EntitySubscription
Supported Calls
create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve()
Fields
| Field | Details |
|---|---|
| NetworkId |
|
| ParentId |
|
| SubscriberId |
|
Usage
Consider this when following records and users:
- Users can only follow records that they can see.
- Users can see which records other users are following, unless they don’t have access to the records.
- Administrators and users with the “Modify All Users” permission can configure a user to follow records that the user has read access to.
- Administrators and users with the “Modify All Users” permission can configure users to stop following records.
- Following topics is available in API version 29.0 and later. For this reason, a topic ID is now a supported value for the ParentId field.
-
If you deactivate a user, any EntitySubscription where the user is associated with the ParentId or SubscriberId field, meaning all subscriptions both to and from the user, are soft deleted. If the user is reactivated, the subscriptions are restored. However, if you deactivate multiple users at once and these users follow each other, their subscriptions are hard deleted. In this case, the user-to-user EntitySubscription is deleted twice (double deleted). Such subscriptions can’t be restored upon user reactivation.
- A query must include a LIMIT clause and the limit can’t exceed 1000.
- 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:
1SELECT Id
2FROM EntitySubscription
3WHERE SubscriberId = '005U0000000Rg2CIAS'
4AND ParentId IN (
5 SELECT Id FROM Account
6 WHERE NumberOfEmployees > 10
7)
8LIMIT 200