Avoid selecting All with access in Salesforce Chatter Post

Avoid selecting All with access in Salesforce Chatter Post

To prevent or avoid users selecting “All with access” in Salesforce Chatter Post, we can develop a Apex Trigger on FeedItem object/entity and throw an error.

Please check the following sample Apex Trigger for reference.

Sample Apex Trigger:

trigger FeedItemTrigger on FeedItem ( before insert ) {
    
    for ( FeedItem objFI : trigger.new ) {
        
        if ( objFI.Visibility == 'AllUsers' ) {
            
            objFI.addError( 
                'Please don\'t select All with access' 
            );
            
        }
        
    }

}

Output:

Leave a Reply