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.
ChatterFavorites Class
Namespace
Usage
Use Connect in Apex to get and delete topics, list views, and feed searches that have been added as favorites. Add topics and feed searches as favorites, and update the last view date of a feed search or list view feed to the current system time.
In this image of Salesforce, “Build Issues” is a topic, “All Accounts” is a list view, and “United” is a feed search.
ChatterFavorites Methods
All methods in this class require Chatter and are subject to the per user, per namespace, per hour rate limit.
addFavorite(communityId, subjectId, searchText)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedFavorite addFavorite(String communityId, String subjectId, String searchText)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- searchText
- Type: String
- Specify the text of the search to be saved as a favorite. This method can only create a feed search favorite, not a list view favorite or a topic.
Return Value
Type: ConnectApi.FeedFavorite
addRecordFavorite(communityId, subjectId, targetId)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedFavorite addRecordFavorite(String communityId, String subjectId, String targetId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- targetId
- Type: String
- The ID of the topic to add as a favorite.
Return Value
Type: ConnectApi.FeedFavorite
deleteFavorite(communityId, subjectId, favoriteId)
API Version
28.0
Requires Chatter
Yes
Signature
public static Void deleteFavorite(String communityId, String subjectId, String favoriteId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
Return Value
Type: Void
getFavorite(communityId, subjectId, favoriteId)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedFavorite getFavorite(String communityId, String subjectId, String favoriteId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
Return Value
Type: ConnectApi.FeedFavorite
getFavorites(communityId, subjectId)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedFavorites getFavorites(String communityId, String subjectId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
Return Value
Type: ConnectApi.FeedFavorites
getFeedElements(communityId, subjectId, favoriteId)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedElementPage getFeedElements(String communityId, String subjectId, String favoriteId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
Return Value
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.
getFeedElements(communityId, subjectId, favoriteId, pageParam, pageSize, sortParam)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedElementPage getFeedElements(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
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:
- CreatedDateAsc—Sorts 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
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.
getFeedElements(communityId, subjectId, favoriteId, recentCommentCount, elementsPerBundle, pageParam, pageSize, sortParam)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedElementPage getFeedElements(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, Integer elementsPerBundle, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
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 to include in a bundle. The value must be an integer between 0 and 10. The default value is 3.
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:
- CreatedDateAsc—Sorts 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
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.
updateFavorite(communityId, subjectId, favoriteId, updateLastViewDate)
API Version
28.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedFavorite updateFavorite(String communityId, String subjectId, String favoriteId, Boolean updateLastViewDate)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
- updateLastViewDate
- Type: Boolean
- Specify whether to update the last view date of the specified favorite to the current system time (true) or not (false).
Return Value
Type: ConnectApi.FeedFavorite
ChatterFavorites Test Methods
For information about using these methods to test your ConnectApi code, see Testing ConnectApi Code.
setTestGetFeedElements(communityId, subjectId, favoriteId, result)
API Version
31.0
Signature
public static Void setTestGetFeedElements(String communityId, String subjectId, String favoriteId, ConnectApi.FeedElementPage result)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
- result
- Type: ConnectApi.FeedElementPage
- Object containing test data.
Return Value
Type: Void
setTestGetFeedElements(communityId, subjectId, favoriteId, pageParam, pageSize, sortParam, result)
API Version
31.0
Signature
public static Void setTestGetFeedElements(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam, ConnectApi.FeedElementPage result)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
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:
- CreatedDateAsc—Sorts 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.
result
Type: ConnectApi.FeedElementPage
Object containing test data.
Return Value
Type: Void
setTestGetFeedElements(communityId, subjectId, favoriteId, recentCommentCount, elementsPerBundle, pageParam, pageSize, sortParam, result)
API Version
31.0
Signature
public static Void setTestGetFeedElements(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, Integer elementsPerBundle, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam, ConnectApi.FeedElementPage result)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
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 to include in a bundle. The value must be an integer between 0 and 10. The default value is 3.
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:
- CreatedDateAsc—Sorts 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.
result
Type: ConnectApi.FeedElementPage
Object containing test data.
Return Value
Type: Void
Retired ChatterFavorites Methods
getFeedItems(communityId, subjectId, favoriteId)
API Version
28.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedItemPage getFeedItems(String communityId, String subjectId, String favoriteId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
Return Value
Type: ConnectApi.FeedItemPage
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.
getFeedItems(communityId, subjectId, favoriteId, pageParam, pageSize, sortParam)
API Version
28.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedItemPage getFeedItems(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
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
Number of feed items 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:
- CreatedDateAsc—Sorts 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.
Sorts the returned feed by the most recently created feed item, or by the most recently modified feed item. If you pass in null, the default value CreatedDateDesc is used.
Return Value
Type: ConnectApi.FeedItemPage
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.
getFeedItems(communityId, subjectId, favoriteId, recentCommentCount, pageParam, pageSize, sortParam)
API Version
29.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.FeedItemPage getFeedItems(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, String pageParam, Integer pageSize, FeedSortOrder sortParam)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed item. The default value is 3.
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
Number of feed items 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:
- CreatedDateAsc—Sorts 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.
Sorts the returned feed by the most recently created feed item, or by the most recently modified feed item. If you pass in null, the default value CreatedDateDesc is used.
Return Value
Type: ConnectApi.FeedItemPage
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.
setTestGetFeedItems(communityId, subjectId, favoriteId, result)
API Version
28.0–31.0
Signature
public static Void setTestGetFeedItems(String communityId, String subjectId, String favoriteId, ConnectApi.FeedItemPage result)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- subjectId
- Type: String
- ID of the context user or the alias me.
- favoriteId
- Type: String
- ID of a favorite.
- result
- Type: ConnectApi.FeedItemPage
- Object containing test data.
Return Value
Type: Void
setTestGetFeedItems(communityId, subjectId, favoriteId, pageParam, pageSize, sortParam, result)
API Version
28.0–31.0
Signature
public static Void setTestGetFeedItems(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, FeedSortOrder sortParam, ConnectApi.FeedItemPage result)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
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
Number of feed items 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:
- CreatedDateAsc—Sorts 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.
Sorts the returned feed by the most recently created feed item, or by the most recently modified feed item. If you pass in null, the default value CreatedDateDesc is used.
result
Type: ConnectApi.FeedItemPage
Object containing test data.
Return Value
Type: Void
setTestGetFeedItems(communityId, subjectId, favoriteId, recentCommentCount, pageParam, pageSize, sortParam, result)
API Version
29.0–31.0
Signature
public static Void setTestGetFeedItems(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, String pageParam, Integer pageSize, FeedSortOrder sortParam, ConnectApi.FeedItemPage result)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
subjectId
Type: String
ID of the context user or the alias me.
favoriteId
Type: String
ID of a favorite.
recentCommentCount
Type: Integer
Maximum number of comments to return with each feed item. The default value is 3.
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
Number of feed items 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:
- CreatedDateAsc—Sorts 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.
Sorts the returned feed by the most recently created feed item, or by the most recently modified feed item. If you pass in null, the default value CreatedDateDesc is used.
result
Type: ConnectApi.FeedItemPage
Object containing test data.
Return Value
Type: Void