Skip to main content
I am working on a requirement where I need to send email to every person in the chatter group as soon as Chatter Comments (FeedComment object) are added to the post. This needs to happen for every comment.

 

I implemented a solution where my trigger is listening to the after insert event and using the ConnectApi to append the @mention of the group name at the end of the comment in a future method.

 

I am relying on the chatter settings of the user to then send email to individuals. We are controlling the Email Notification settings for the user. Only the checkboxes shown on the below screenshot are turned on for chatter notification.

 

We did one time cleanup so all the users have the same chatter configuration and also trigger on user object is in place to keep the chatter settings intact.

 

However, this is causing people in the chatter group to receive email two times.

 

How to update chatter comment on before insert trigger?

 

The support is saying our triggers are getting called two times because of which duplicate emails are going out. But the trigger is not listening to after or before update event and also we are not seeing two @mention of group name at the end of the comment. Trigger looks like this:

 

trigger FeedCommentTrigger on FeedComment (after insert) {

 

    if(trigger.isAfter){

 

        if(trigger.isInsert){

 

            FeedCommentTriggerHandler.handleAfterInsert(Trigger.new);

 

        }

 

    }

 

}

 

Any idea why users are getting two emails?

 

One solution, I was thinking about is be able to modify the comment text in the before trigger so that I don't have to specifically call ConnectApi.ChatterFeeds.updateComment method on the after insert event.

 

Is it possible to modify the comment text in the before trigger and if so can someone please share sample code with me?

 

 
1 answer
  1. Aug 3, 2017, 5:38 AM
     I would Suggest you to Please redirect your question into Salesforce Developer Forum and Stack Exchange. As this community is based on Configuration and Customization Part.

     

    https://developer.salesforce.com/forums#!/feedtype=RECENT&criteria=ALLQUESTIONS& (https://developer.salesforce.com/forums#!/feedtype=RECENT&criteria=ALLQUESTIONS&" target="_blank)

     

    https://salesforce.stackexchange.com/ (https://salesforce.stackexchange.com/" target="_blank)
0/9000