Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Chatter Class
Namespace
Chatter Methods
deleteSubscription(communityId, subscriptionId)
API Version
28.0
Requires Chatter
Yes
Signature
public static void deleteSubscription(String communityId, String subscriptionId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subscriptionId
- Type: String
- The ID for a subscription.
Return Value
Type: Void
Usage
To leave a group, call deleteMember(communityId, membershipId).
Example
When you follow a user, the call to ConnectApi.ChatterUsers.follow returns a ConnectApi.Subscription object. To stop following the user, pass the id property of that object to this method.
1ConnectApi.Chatter.deleteSubscription(null, '0E8RR0000004CnK0AU');getFollowers(communityId, recordId)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.FollowerPage getFollowers(String communityId, String recordId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- recordId
- Type: String
- ID for a record or the keyword me.
Return Value
Type: ConnectApi.FollowerPage
Usage
getFollowers(communityId, recordId, pageParam, pageSize)
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
- ID for an Experience Cloud site, internal, or null.
- recordId
- Type: String
- ID for a record or the keyword me.
- pageParam
- Type: Integer
- 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 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)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.Subscription getSubscription(String communityId, String subscriptionId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subscriptionId
- Type: String
- The ID for a subscription.
Return Value
Type: ConnectApi.Subscription
Usage
submitDigestJob(period)
API Version
37.0
Requires Chatter
Yes
Signature
public static ConnectApi.DigestJobRepresentation submitDigestJob(ConnectApi.DigestPeriod period)
Parameters
period
Type: ConnectApi.DigestPeriod
Time period that’s 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
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
1global class ExampleDigestJob1 implements Schedulable {
2 global void execute(SchedulableContext context) {
3 ConnectApi.Chatter.submitDigestJob(ConnectApi.DigestPeriod.DailyDigest);
4 }
5}1global class ExampleDigestJob2 implements Schedulable {
2 global void execute(SchedulableContext context) {
3 ConnectApi.Chatter.submitDigestJob(ConnectApi.DigestPeriod.WeeklyDigest);
4 }
5}