Skip to main content

I want to get only EmailMessageEvent feeds for a Case. I found two types of filtering criteria in : ConnectApi.ChatterFeeds.getFeedElementsFromFeed

  1. using ConnectApi.FeedType in  getFeedElementsFromFeed(communityId, feedType, subjectId)
  2. using ConnectApi.​FeedFilter in  getFeedElementsFromFeed(communityId, feedType, subjectId, recentCommentCount, density, pageParam, pageSize, sortParam, filter)  

References :  Chatter Feed Class

Connected API Enums

 

Is there any way to filter by ConnectApi.​FeedItemType

1 respuesta
  1. 4 dic 2024, 16:05

    @Aman Sharma,

     

    Regretfully, Chatter feeds cannot be directly filtered using ConnectApi.Use the getFeedElementsFromFeed function to feedItemType.

    The ConnectApi.FeedType and ConnectApi.FeedFilter filters are intended for more general filtering criteria, including filtering by feed type (e.g., record feed, group feed), or by more focused filters, like "recent comments" or "my posts."

     

    you can indirectly achieve the desired filtering by combining the following approaches:

    1. Retrieve All Feed Elements:
      • Use getFeedElementsFromFeed to fetch all feed elements for a specific Case.
    2. Filter in Apex:
      • Iterate through the retrieved feed elements and filter them based on their type attribute.
      • Keep only the EmailMessageEvent feed items.

    Here's a code example:

     

    List<ConnectApi.FeedItem> feedItems = ConnectApi.ChatterFeeds.getFeedElementsFromFeed(null, ConnectApi.FeedType.Record, caseId);

     

    List<ConnectApi.FeedItem> emailMessageEvents = new List<ConnectApi.FeedItem>();

    for (ConnectApi.FeedItem item : feedItems) {

        if (item.type == ConnectApi.FeedItemType.EmailMessageEvent) {

            emailMessageEvents.add(item);

        }

    }

0/9000