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:
The following are methods for ChatterFavorites. All methods are static.
28.0
Yes
public static ConnectApi.FeedFavorite addFavorite(String communityId, String subjectId, String searchText)
Type: ConnectApi.FeedFavorite
28.0
Yes
public static ConnectApi.FeedFavorite addRecordFavorite(String communityId, String subjectId, String targetId)
Type: ConnectApi.FeedFavorite
28.0
Yes
public static Void deleteFavorite(String communityId, String subjectId, String favoriteId)
Type: Void
28.0
Yes
public static ConnectApi.FeedFavorite getFavorite(String communityId, String subjectId, String favoriteId)
Type: ConnectApi.FeedFavorite
28.0
Yes
public static ConnectApi.FeedFavorites getFavorites(String communityId, String subjectId)
Type: ConnectApi.FeedFavorites
31.0
Yes
public static ConnectApi.FeedElementPage getFeedElements(String communityId, String subjectId, String favoriteId)
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.
31.0
Yes
public static ConnectApi.FeedElementPage getFeedElements(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)
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.
31.0
Yes
public static ConnectApi.FeedElementPage getFeedElements(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, Integer elementsPerBundle, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)
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.
28.0
Yes
public static ConnectApi.FeedFavorite updateFavorite(String communityId, String subjectId, String favoriteId, Boolean updateLastViewDate)
Type: ConnectApi.FeedFavorite
The following are the test methods for ChatterFavorites. All methods are static.
For information about using these methods to test your ConnectApi code, see Testing ConnectApi Code.
31.0
public static Void setTestGetFeedElements(String communityId, String subjectId, String favoriteId, ConnectApi.FeedElementPage result)
Type: Void
31.0
public static Void setTestGetFeedElements(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam, ConnectApi.FeedElementPage result)
Type: Void
31.0
public static Void setTestGetFeedElements(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, Integer elementsPerBundle, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam, ConnectApi.FeedElementPage result)
Type: Void
The following methods for ChatterFavorites are retired.
Yes
public static ConnectApi.FeedItemPage getFeedItems(String communityId, String subjectId, String favoriteId)
Type: ConnectApi.FeedItemPage
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.
Yes
public static ConnectApi.FeedItemPage getFeedItems(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, ConnectApi.FeedSortOrder sortParam)
Type: ConnectApi.FeedItemPage
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.
Yes
public static ConnectApi.FeedItemPage getFeedItems(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, String pageParam, Integer pageSize, FeedSortOrder sortParam)
Type: ConnectApi.FeedItemPage
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.
28.0–31.0
public static Void setTestGetFeedItems(String communityId, String subjectId, String favoriteId, ConnectApi.FeedItemPage result)
Type: Void
28.0–31.0
public static Void setTestGetFeedItems(String communityId, String subjectId, String favoriteId, String pageParam, Integer pageSize, FeedSortOrder sortParam, ConnectApi.FeedItemPage result)
Type: Void
29.0–31.0
public static Void setTestGetFeedItems(String communityId, String subjectId, String favoriteId, Integer recentCommentCount, String pageParam, Integer pageSize, FeedSortOrder sortParam, ConnectApi.FeedItemPage result)
Type: Void