function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KRayKRay 

Exclude Multiple FeedTypes from Chatter Feed

HI Forum, 
I'm looking to exclude multiple FeedItemTypes from the Chatter Feed using the Chatter:Feed or Chatter:FeedWithFollowers elements.  From my research, Chatter:FeedWithFollowers doesn't have a property/method to exclude feedtItemTypes but there has to be a way to add the functionality.  I've posted a snippet of apex & visualforce code below.   The apex method returns a String of values but from the looks of it, I can only include or exclude a single string value using the Chatter:Feed element.  Help?!?
//Apex Snippet
public String getChatterTypes(){
   
        List<String> allTypes = new List<String>{
          'AttachArticleEvent',
           'CallLogPost',
           'CaseCommentPost',
           'ChangeStatusPost',
           'ChatTranscriptPost'};

            //Excluding  EmailMessageEvent
           
          
          String availableValues = String.join(allTypes, ',');
          
          return availableValues;    
    }
 
//Visualforce Snippet
<apex:page standardController="Case" extensions="redirectCaseController">

        <chatter:feed entityId="{!Case.ID}" feedItemType="{!ChatterTypes}" />

        <apex:detail />

</apex:page>

 
Best Answer chosen by KRay
KRayKRay
For all that are wondering, I found the answer!!!!  Unfortunately, there isn't an attribute or standard solution for this so, I created my own using a vf page, vf component, css, apex, and jquery.

Here's how it works:
  1. During initial page load, the chatter feed will be hidden from the view by the css snippet. 
  2. If the apex logic validates to TRUE, jquery will hide the email (EmailMessageEvent) chatter posts then show the customized chatter feed. 
Apex Method:
//For this demo, I'm simply returning true. Add whatever logic you deem necessary
public Boolean getCanUserViewEmails(){
//add logic to verify the logged in user's access
return true;
}

Visualforce Page:
<apex:page standardController="Case" extensions="customCaseController" 
  
    <c:ChatterFeedFollowersWithExclusions Case="{!Case}" hasAccess="{!CanUserViewEmails}" />
    <apex:detail />

</apex:page>

VisualforceComponent:
<apex:component >

    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"/>
    <apex:includeScript value="/support/console/28.0/integration.js"/>
    
    <apex:attribute name="Case" type="Case" required="true" description="Contains the entity Id"/>
    <apex:attribute name="hasAccess" type="Boolean" required="true" description="Used to render the Chatter Feed based on the user's access"/>
  
 //ADD CSS HERE

      
    <chatter:feedWithFollowers entityId="{!Case.Id}" id="customChatterFeed" />

  //ADD JQUERY HERE
 
</apex:component>
CSS:
<style>
      .chatterfeedshell{
          display:none;
          }
    </style>



JQuery:
<script type ="text/javascript">   
           
           if( {!hasAccess} ){
               
               $('[class="feeditemaux cxfeeditemaux EmailMessageAuxBody"]').parents(".feeditembody").siblings(".feeditemfooter").css("display","none");
               $('[class="feeditemaux cxfeeditemaux EmailMessageAuxBody"]').parents(".cxfeeditem.feeditem").css("display","none");
               $('[class="chatterfeedshell"]').show();
               
           } else {
           
               $('[class="chatterfeedshell"]').show();
               
           }
   </script>