ChatterFeeds Class

Get, post, and delete feed elements, likes, comments, and bookmarks. You can also search feed elements, share feed elements, and vote on polls.

Namespace

ConnectApi

Usage

The Chatter feed is a container of feed elements. The abstract class ConnectApi.FeedElement is a parent class to the ConnectApi.FeedItem class, representing feed posts, and the ConnectApi.GenericFeedElement class, representing bundles and recommendations in the feed. For detailed information, see Working with Feeds and Feed Elements.

Feed item methods aren’t available in version 32.0. In version 32.0 and later, use feed element methods.

Important

Message segments in a feed item are typed as ConnectApi.MessageSegment. Feed item capabilities are typed as ConnectApi.FeedItemCapability. Record fields are typed as ConnectApi.AbstractRecordField. These classes are all abstract and have several concrete subclasses. At runtime you can use instanceof to check the concrete types of these objects and then safely proceed with the corresponding downcast. When you downcast, you must have a default case that handles unknown subclasses.

The composition of a feed can change between releases. Write your code to handle instances of unknown subclasses.

Important

ChatterFeeds Methods

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

createStream(communityId, streamInput)

Create a Chatter feed stream.

API Version

39.0

Requires Chatter

Yes

Signature

public static ConnectApi.ChatterStream createStream(String communityId, ConnectApi.ChatterStreamInput streamInput)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
streamInput
Type: ConnectApi.ChatterStreamInput
A ConnectApi.ChatterStreamInput body.

Return Value

Type: ConnectApi.ChatterStream

deleteComment(communityId, commentId)

Delete a comment.

API Version

28.0

Requires Chatter

Yes

Signature

public static Void deleteComment(String communityId, String commentId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.

Return Value

Type: Void

deleteFeedElement(communityId, feedElementId)

Delete a feed element.

API Version

31.0

Requires Chatter

Yes

Signature

public static deleteFeedElement(String communityId, String feedElementId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.

Return Value

Type: Void

deleteLike(communityId, likeId)

Delete a like on a comment or post.

API Version

28.0

Requires Chatter

Yes

Signature

public static Void deleteLike(String communityId, String likeId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
likeId
Type: String
ID for a like.

Return Value

Type: Void

deleteStream(communityId, streamId)

Delete a Chatter feed stream.

API Version

39.0

Requires Chatter

Yes

Signature

public static Void deleteStream(String communityId, String streamId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
streamId
Type: String
ID of the Chatter feed stream.

Return Value

Type: Void

getComment(communityId, commentId)

Get a comment.

API Version

28.0

Available to Guest Users

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.Comment getComment(String communityId, String commentId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.

Return Value

Type: ConnectApi.​Comment

getCommentBatch(communityId, commentIds)

Get a list of comments.

API Version

42.0

Requires Chatter

Yes

Signature

public static ConnectApi.BatchResult[] getCommentBatch(String communityId, List<String> commentIds)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentIds
Type: List<String>
A list of up to 100 comment IDs.

Return Value

Type: ConnectApi.BatchResult[]

The ConnectApi.BatchResult.getResult() method returns a ConnectApi.Comment object and errors for comments that didn’t load.

getCommentInContext(communityId, commentId, pageSize)

Get a threaded comment in the context of its parent comments and post.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getCommentInContext(String communityId, String commentId, Integer pageSize)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID of the comment.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you don’t specify a value, the default size is 25.

Return Value

Type: ConnectApi.FeedElement

If the comment doesn’t support the comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId)

Get comments for a feed element.

API Version

32.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentPage getCommentsForFeedElement(String communityId, String feedElementId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.

Return Value

Type: ConnectApi.CommentPage

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, threadedCommentsCollapsed)

Get comments in a threaded style for a feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentPage getCommentsForFeedElement(String communityId, String feedElementId, Boolean threadedCommentsCollapsed)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.

Return Value

Type: ConnectApi.CommentPage

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, pageParam, pageSize)

Get a page of comments for a feed element.

API Version

32.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentPage getCommentsForFeedElement(String communityId, String feedElementId, String pageParam, Integer pageSize)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of comments per page. Valid values are from 1 through 100. If you pass null, the default size is 25.

Return Value

Type: ConnectApi.CommentPage

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, pageParam, pageSize, threadedCommentsCollapsed)

Get a page of comments in a threaded style for a feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentPage getCommentsForFeedElement(String communityId, String feedElementId, String pageParam, Integer pageSize, Boolean threadedCommentsCollapsed)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of comments per page. Valid values are from 1 through 100. If you pass null, the default size is 25.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.

Return Value

Type: ConnectApi.CommentPage

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, threadedCommentsCollapsed, sortParam)

Get sorted comments in a threaded style for a feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentsCapability getCommentsForFeedElement(String communityId, String feedElementId, Boolean threadedCommentsCollapsed, ConnectApi.FeedCommentSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.
sortParam
Type: ConnectApi.FeedCommentSortOrder
Order of comments. Values are:
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.CommentPage

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, pageParam, pageSize, threadedCommentsCollapsed, sortParam)

Get a page of sorted comments in a threaded style for a feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentPage getCommentsForFeedElement(String communityId, String feedElementId, String pageParam, Integer pageSize, Boolean threadedCommentsCollapsed, ConnectApi.FeedCommentSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of comments per page. Valid values are from 1 through 100. If you pass null, the default size is 25.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.
sortParam
Type: ConnectApi.FeedCommentSortOrder
Order of comments. Values are:
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.CommentPage

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, sortParam)

Get sorted comments for a feed element.

API Version

41.0

Available to Guest Users

41.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentsCapability getCommentsForFeedElement(String communityId, String feedElementId, ConnectApi.FeedCommentSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
sortParam
Type: ConnectApi.FeedCommentSortOrder
Order of comments. Values are:
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.CommentsCapability

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getCommentsForFeedElement(communityId, feedElementId, sortParam, threadedCommentsCollapsed)

Get sorted comments in a threaded style for a feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.CommentsCapability getCommentsForFeedElement(String communityId, String feedElementId, ConnectApi.FeedCommentSortOrder sortParam, Boolean threadedCommentsCollapsed)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
sortParam
Type: ConnectApi.FeedCommentSortOrder
Order of comments. Values are:
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.

Return Value

Type: ConnectApi.CommentsCapability

If the feed element doesn’t support the Comments capability, the return value is ConnectApi.NotFoundException.

getExtensions(communityId, pageParam, pageSize)

Get extensions.

API Version

40.0

Available to Guest Users

40.0

Requires Chatter

Yes

Signature

public static ConnectApi.ExtensionDefinitions getExtensions(String communityId, String pageParam, Integer pageSize)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
pageParam
Type: String
Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. The default size is 15.

Return Value

Type: ConnectApi.ExtensionDefinitions

getFeed(communityId, feedType)

Get a feed.

API Version

28.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.Feed getFeed(String communityId, ConnectApi.FeedType feedType)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values are Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview.

Return Value

Type: ConnectApi.Feed

getFeed(communityId, feedType, sortParam)

Get a sorted feed.

API Version

28.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.Feed getFeed(String communityId, ConnectApi.FeedType feedType, ConnectApi.FeedSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values are Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview.
sortParam
Type: ConnectApi.​FeedSortOrder
Values are:
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
If you pass in null, the default value CreatedDateDesc is used.

If feedType is DirectMessages, sortParam must be LastModifiedDateDesc.

Return Value

Type: ConnectApi.Feed

getFeed(communityId, feedType, subjectId)

Get a feed for a record or user.

API Version

28.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.Feed getFeed(String communityId, ConnectApi.FeedType feedType, String subjectId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values include every ConnectApi.FeedType except Company, DirectMessageModeration, DirectMessages, Filter, Home, Isolated, Landing, Moderation, and PendingReview.
subjectId
Type: String
If feedType is Record, subjectId can be any record ID, including a group ID. If feedType is Streams, subjectId must be a stream ID. If feedType is Topics, subjectId must be a topic ID. If feedType is UserProfile, subjectId can be any user ID. If the feedType is any other value, subjectId must be the ID of the context user or the alias me.

Return Value

Type: ConnectApi.Feed

getFeed(communityId, feedType, subjectId, sortParam)

Get a sorted feed for a record or user.

API Version

28.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.Feed getFeed(String communityId, ConnectApi.FeedType feedType, String subjectId, ConnectApi.FeedSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values include every ConnectApi.FeedType except Company, DirectMessageModeration, DirectMessages, Filter, Home, Isolated, Landing, Moderation, and PendingReview.
subjectId
Type: String
If feedType is Record, subjectId can be any record ID, including a group ID. If feedType is Streams, subjectId must be a stream ID. If feedType is Topics, subjectId must be a topic ID. If feedType is UserProfile, subjectId can be any user ID. If the feedType is any other value, subjectId must be the ID of the context user or the alias me.
sortParam
Type: ConnectApi.​FeedSortOrder
Values are:
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
If you pass in null, the default value CreatedDateDesc is used.

Return Value

Type: ConnectApi.Feed

getFeedDirectory(String)

Get a list of all feeds available to the context user.

API Version

30.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedDirectory getFeedDirectory(String communityId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.

Return Value

Type: ConnectApi.FeedDirectory

getFeedElement(communityId, feedElementId)

Get a feed element.

API Version

31.0

Available to Guest Users

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, commentSort)

Get a feed element with sorted comments.

API Version

41.0

Available to Guest Users

41.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, ConnectApi.FeedCommentSortOrder commentSort)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
commentSort
Type: ConnectApi.FeedCommentSortOrder
Order of comments.
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
The default value is CreatedDateLatestAsc.

Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, threadedCommentsCollapsed)

Get a feed element and its comments in a threaded style.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, Boolean threadedCommentsCollapsed)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, threadedCommentsCollapsed, commentSort)

Get a feed element and its sorted comments in a threaded style.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, Boolean threadedCommentsCollapsed, ConnectApi.FeedCommentSortOrder commentSort)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.
commentSort
Type: ConnectApi.FeedCommentSortOrder
Order of comments.
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, recentCommentCount, elementsPerBundle)

Get a feed element with the specified number of elements per bundle including no more than the specified number of comments per feed element.

API Version

31.0

Available to Guest Users

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, Integer recentCommentCount, Integer elementsPerBundle)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed element. The default value is 3.
elementsPerBundle
Type: Integer
Maximum number of feed elements per bundle. The default and maximum value is 10.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, recentCommentCount, elementsPerBundle, threadedCommentsCollapsed)

Get a feed element with its comments in a threaded style with the specified number of elements per bundle and comments per feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, Integer recentCommentCount, Integer elementsPerBundle, Boolean threadedCommentsCollapsed)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed element. The default value is 3.
elementsPerBundle
Type: Integer
Maximum number of feed elements per bundle. The default and maximum value is 10.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, recentCommentCount, elementsPerBundle, threadedCommentsCollapsed, commentSort)

Get a feed element with its sorted comments in a threaded style with the specified number of elements per bundle and comments per feed element.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, Integer recentCommentCount, Integer elementsPerBundle, Boolean threadedCommentsCollapsed, ConnectApi.FeedCommentSortOrder commentSort)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed element. The default value is 3.
elementsPerBundle
Type: Integer
Maximum number of feed elements per bundle. The default and maximum value is 10.
threadedCommentsCollapsed
Type: Boolean
Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you pass in null, the default is false.
commentSort
Type: ConnectApi.FeedCommentSortOrder
Order of comments.
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.FeedElement

getFeedElement(communityId, feedElementId, recentCommentCount, elementsPerBundle, commentSort)

Get a feed element with the specified number of elements per bundle including no more than the specified number of sorted comments per feed element.

API Version

41.0

Available to Guest Users

41.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElement getFeedElement(String communityId, String feedElementId, Integer recentCommentCount, Integer elementsPerBundle, ConnectApi.FeedCommentSortOrder commentSort)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed element. The default value is 3.
elementsPerBundle
Type: Integer
Maximum number of feed elements per bundle. The default and maximum value is 10.
commentSort
Type: ConnectApi.FeedCommentSortOrder
Order of comments.
  • CreatedDateLatestAsc—Sorts by most recently created comments in ascending order.
  • CreatedDateOldestAsc—Sorts by oldest comments in ascending order.
  • Relevance—Sorts by most relevant content.
The default value is CreatedDateLatestAsc.

Sorting in descending order isn’t supported.

Return Value

Type: ConnectApi.FeedElement

getFeedElementBatch(communityId, feedElementIds)

Get a list of feed elements.

API Version

31.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.BatchResult[] getFeedElementBatch(String communityId, List<String> feedElementIds)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementIds
Type: List<String>
A list of up to 500 feed element IDs.

Return Value

Type: ConnectApi.BatchResult[]

The ConnectApi.BatchResult.getResult() method returns a ConnectApi.FeedElement object and errors for feed elements that didn’t load.

getFeedElementPoll(communityId, feedElementId)

Get the poll associated with a feed element.

API Version

32.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.PollCapability getFeedElementPoll(String communityId, String feedElementId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.

Return Value

Type: ConnectApi.PollCapability

If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.

Triggers on FeedItem objects run before their attachment and capabilities information is saved, which means that ConnectApi.FeedItem.attachment information and ConnectApi.FeedElement.capabilities information may not be available in the trigger.

Note

getFeedElementsFromBundle(communityId, feedElementId)

Get feed elements from a bundle.

API Version

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromBundle(String communityId, String feedElementId)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.

Return Value

Type: ConnectApi.FeedElementPage

getFeedElementsFromBundle(communityId, feedElementId, pageParam, pageSize, elementsPerBundle, recentCommentCount)

Get a page of feed elements from a bundle. Specify the number of elements per bundle and include no more than the specified number of comments per feed element.

API Version

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromBundle(String communityId, String feedElementId, String pageParam, Integer pageSize, Integer elementsPerBundle, Integer recentCommentCount)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
pageParam
Type: String
Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of feed elements per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
elementsPerBundle
Type: Integer
Maximum number of feed elements per bundle. The default and maximum value is 10.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed element. The default value is 3.

Return Value

Type: ConnectApi.FeedElementPage

getFeedElementsFromFeed(communityId, feedType)

Get feed elements from the Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview feeds.

API Version

31.0

Available to Guest Users

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromFeed(String communityId, ConnectApi.FeedType feedType)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values are Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview.

Return Value

Type: ConnectApi.FeedElementPage

Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getFeedElementsFromFeed(communityId, feedType, pageParam, pageSize, sortParam)

Get a page of sorted feed elements from the Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview feeds.

API Version

31.0

Available to Guest Users

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromFeed(String communityId, ConnectApi.FeedType feedType, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values are Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of feed elements per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
sortParam
Type: ConnectApi.​FeedSortOrder
Values are:
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
If you pass in null, the default value CreatedDateDesc is used.

If feedType is DirectMessages, sortParam must be LastModifiedDateDesc.

Return Value

Type: ConnectApi.FeedElementPage

Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getFeedElementsFromFeed(communityId, feedType, recentCommentCount, density, pageParam, pageSize, sortParam)

Get a page of sorted feed elements from the Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview feeds. Each feed element contains no more than the specified number of comments.

API Version

31.0

Available to Guest Users

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromFeed(String communityId, ConnectApi.FeedType feedType, Integer recentCommentCount, ConnectApi.FeedDensity density, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
Type of feed. Valid values are Company, DirectMessageModeration, DirectMessages, Home, Isolated, Moderation, and PendingReview.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed item. The default value is 3.
density
Type: ConnectApi.​FeedDensity
Specify the amount of content in a feed.
  • AllUpdates—Displays all updates from people and records the user follows and groups the user is a member of. Also displays custom recommendations.
  • FewerUpdates—Displays all updates from people and records the user follows and groups the user is a member of. Also displays custom recommendations, but hides some system-generated updates from records.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
pageSize
Type: Integer
Specifies the number of feed elements per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.
sortParam
Type: ConnectApi.​FeedSortOrder
Values are:
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
If you pass in null, the default value CreatedDateDesc is used.

If feedType is DirectMessages, sortParam must be LastModifiedDateDesc.

Return Value

Type: ConnectApi.FeedElementPage

Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getFeedElementsFromFeed(communityId, feedType, recentCommentCount, density, pageParam, pageSize, sortParam, filter)

Get a page of sorted and filtered feed elements from the Home feed. Each feed element contains no more than the specified number of comments.

API Version

32.0

Available to Guest Users

32.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromFeed(String communityId, ConnectApi.FeedType feedType, Integer recentCommentCount, ConnectApi.FeedDensity density, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam, ConnectApi.FeedFilter filter)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.​FeedType
The type of feed. The only valid value is Home.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed item. The default value is 3.
density
Type: ConnectApi.​FeedDensity
Specify the amount of content in a feed.
  • AllUpdates—Displays all updates from people and records the user follows and groups the user is a member of. Also displays custom recommendations.
  • FewerUpdates—Displays all updates from people and records the user follows and groups the user is a member of. Also displays custom recommendations, but hides some system-generated updates from records.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.

When the sortParam is MostViewed, you must pass in null for the pageParam.

pageSize
Type: Integer
Specifies the number of feed elements per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

When the sortParam is MostViewed, the pageSize must be a value from 1 to 25.

sortParam
Type: ConnectApi.​FeedSortOrder
Values are:
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
If you pass in null, the default value CreatedDateDesc is used.
filter
Type: ConnectApi.​FeedFilter
Specifies the feed filters.
  • AllQuestions—Feed elements that are questions.
  • AuthoredBy—Feed elements authored by the user profile owner. This value is valid only for the UserProfile feed.
  • CommunityScoped—Feed elements that are scoped to Experience Cloud sites. Currently, these feed elements have a User or a Group parent record. However, other parent record types could be scoped to sites in the future. Feed elements that are always visible in all sites are filtered out. This value is valid only for the UserProfile feed.
  • QuestionsWithCandidateAnswersFeed elements that are questions that have candidate answers associated with them. This value is valid only for users with the Access Einstein-Generated Answers permission.
  • QuestionsWithCandidateAnswers​ReviewedPublishedFeed elements that are questions that have candidate answers that have been reviewed or published. This value is valid only for users with the Access Einstein-Generated Answers permission.
  • Read—Feed elements that are older than 30 days or are marked as read for the context user. Includes existing feed elements when the context user joined the group. This value is valid only for the Record feed of a group.
  • SolvedQuestions—Feed elements that are questions and that have a best answer.
  • UnansweredQuestions—Feed elements that are questions and that don’t have any answers.
  • UnansweredQuestionsWithCandidate​AnswersFeed elements that are questions that don’t have answers but have candidate answers associated with them. This value is valid only for users with the Access Einstein-Generated Answers permission.
  • Unread—Feed elements that are created in the past 30 days and aren’t marked as read for the context user. This value is valid only for the Record feed of a group.
  • UnsolvedQuestions—Feed elements that are questions and that don’t have a best answer.

Return Value

Type: ConnectApi.FeedElementPage

Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getFeedElementsFromFeed(communityId, feedType, recentCommentCount, density, pageParam, pageSize, sortParam, filter, threadedCommentsCollapsed)

Get a page of filtered and sorted feed elements with comments in a threaded style from the Home feed. Each feed element contains no more than the specified number of comments.

API Version

44.0

Available to Guest Users

44.0

Requires Chatter

Yes

Signature

public static ConnectApi.FeedElementPage getFeedElementsFromFeed(String communityId, ConnectApi.FeedType feedType, Integer recentCommentCount, ConnectApi.FeedDensity density, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam, ConnectApi.FeedFilter filter, Boolean threadedCommentsCollapsed)

Parameters

communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedType
Type: ConnectApi.FeedType
The type of feed. The only valid value is Home.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed item. The default value is 3.
density
Type: ConnectApi.FeedDensity
Specify the amount of content in a feed.
  • AllUpdates—Displays all updates from people and records the user follows and groups the user is a member of. Also displays custom recommendations.
  • FewerUpdates—Displays all updates from people and records the user follows and groups the user is a member of. Also displays custom recommendations, but hides some system-generated updates from records.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.

When the sortParam is MostViewed, you must pass in null for the pageParam.

pageSize
Type: Integer
Specifies the number of feed elements per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

When the sortParam is MostViewed, the pageSize must be a value from 1 to 25.

sortParam
Type: ConnectApi.FeedSortOrder
Values are:
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
If you pass in null, the default value CreatedDateDesc is used.
filter
Type: ConnectApi.FeedFilter
Specifies the feed filters.
  • AllQuestions—Feed elements that are questions.
  • AuthoredBy—Feed elements authored by the user profile owner. This value is valid only for the UserProfile feed.
  • CommunityScoped—Feed elements that are scoped to Experience Cloud sites. Currently, these feed elements have a User or a Group parent record. However, other parent record types could be scoped to sites in the future. Feed elements that are always visible in all sites are filtered out. This value is valid only for the UserProfile feed.
  • QuestionsWithCandidateAnswersFeed elements that are questions that have candidate answers associated with them. This value is valid only for users with the Access Einstein-Generated Answers permission.
  • QuestionsWithCandidateAnswers​ReviewedPublishedFeed elements that are questions that have candidate answers that have been reviewed or published. This value is valid only for users with the Access Einstein-Generated Answers permission.
  • Read—Feed elements that are older than