Chatter Class

Access information about followers and subscriptions for records.

Namespace

ConnectApi

Chatter Methods

The following are methods for Chatter. All methods are static.

deleteSubscription(communityId, subscriptionId)

Deletes the specified subscription. Use this method to unfollow a record, a user, or a file.

API Version

28.0

Requires Chatter

Yes

Signature

public static void deleteSubscription(String communityId, String subscriptionId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
subscriptionId
Type: String
The ID for a subscription.

Return Value

Type: Void

Usage

“Following” a user, group, or record is the same as “subscribing” to a user, group, or record. A “follower” is the user who followed the user, group, or record. A “subscription” is an object describing the relationship between the follower and the user, group, or record they followed.

To leave a group, call deleteMember(communityId, membershipId).

getFollowers(communityId, recordId)

Returns the first page of followers for the specified record in the specified community. The page contains the default number of items.

API Version

28.0

Requires Chatter

Yes

Signature

public static ConnectApi.FollowerPage getFollowers(String communityId, String recordId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recordId
Type: String
The ID for a record or the keyword me.

Return Value

Type: ConnectApi.​FollowerPage

Usage

“Following” a user, group, or record is the same as “subscribing” to a user, group, or record. A “follower” is the user who followed the user, group, or record. A “subscription” is an object describing the relationship between the follower and the user, group, or record they followed.

getFollowers(communityId, recordId, pageParam, pageSize)

Returns the specified page of followers for the specified record.

API Version

28.0

Requires Chatter

Yes

Signature

public static ConnectApi.FollowerPage getFollowers(String communityId, String recordId, Integer pageParam, Integer pageSize)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recordId
Type: String
The ID for a record or the keyword me.
pageParam
Type: Integer
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: Integer
Specifies the number of feed items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

Return Value

Type: ConnectApi.​FollowerPage

Usage

“Following” a user, group, or record is the same as “subscribing” to a user, group, or record. A “follower” is the user who followed the user, group, or record. A “subscription” is an object describing the relationship between the follower and the user, group, or record they followed.

getSubscription(communityId, subscriptionId)

Returns information about the specified subscription.

API Version

28.0

Requires Chatter

Yes

Signature

public static ConnectApi.Subscription getSubscription(String communityId, String subscriptionId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
subscriptionId
Type: String
The ID for a subscription.

Return Value

Type: ConnectApi.​Subscription

Usage

“Following” a user, group, or record is the same as “subscribing” to a user, group, or record. A “follower” is the user who followed the user, group, or record. A “subscription” is an object describing the relationship between the follower and the user, group, or record they followed.

submitDigestJob(period)

Submit a daily or weekly Chatter email digest job.

API Version

37.0

Requires Chatter

Yes

Signature

public static ConnectApi.DigestJobRepresentation submitDigestJob(ConnectApi.DigestPeriod period)

Parameters

period
Type: ConnectApi.DigestPeriod
Specifies the period of time that is included in a Chatter email digest. Values are:
  • DailyDigest—The email includes up to the 50 latest posts from the previous day.
  • WeeklyDigest—The email includes up to the 50 latest posts from the previous week.

Return Value

Type: ConnectApi.DigestJob

Usage

The times when Chatter sends email digests are not configurable in the UI. To control when email digests are sent and to use this method, contact Salesforce to enable API-only Chatter Digests.
Warning

Warning

Enabling API-only Chatter Digests disables the scheduled digests for your org. You must call the API for your users to receive their digests.

We recommend scheduling digest jobs by implementing the Apex Schedulable interface with this method. To monitor your digest jobs from Setup, enter Background Jobs in the Quick Find box, then select Background Jobs.

Example

Schedule daily digests:
global class ExampleDigestJob1 implements Schedulable {
   global void execute(SchedulableContext context) {
      ConnectApi.Chatter.submitDigestJob(ConnectApi.DigestPeriod.DailyDigest);
   }
}
Schedule weekly digests:
global class ExampleDigestJob2 implements Schedulable {
   global void execute(SchedulableContext context) {
      ConnectApi.Chatter.submitDigestJob(ConnectApi.DigestPeriod.WeeklyDigest);
   }
}