2

I'm coding a trigger for "FeedItem" to automatically add a mention to a certain user.

I'm following pretty much the same logic stated here (by adding a new mention segment to the feed input):

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_edit_feed_element.htm

When calling ConnectAPI.updateFeedElement from the trigger, the mention is successfully added; however for some weird reason the mentioned user receives 2 email notifications instead of one.

If the same logic is applied outside of a trigger (running from anonymous for example) the user receives only 1 notification.

Any ideas?

4
  • 2
    I'm seeing this in an "after insert" FeedItem trigger too. I think that both the insert and the update are causing email notifications to be sent. I work at Salesforce and am checking with the team to see what we can do. If you need to contact support, please reference work record W-2840463.
    – alouie
    Commented Nov 24, 2015 at 21:49
  • 2
    @alouie I've already opened a case (12798629), it seems like a Salesforce bug. Will update here with the findings. Thank you Commented Nov 25, 2015 at 8:33
  • @alouie was there ever an update on this issue? I'm also seeing this exact issue.
    – John_Henry
    Commented Oct 19, 2016 at 16:02
  • 1
    @John_Yankee, unfortunately there wasn't a fix.
    – alouie
    Commented Oct 20, 2016 at 22:15

1 Answer 1

0

I struggled with this as well. According to Salesforce, this is 'working as designed.' You must put your logic in a future method if you are adding mentions in an after insert trigger. https://help.salesforce.com/articleView?id=000321239&language=en_US&type=1&mode=1

In my experience, though, even doing this sometimes causes duplicate emails to be sent, seemingly randomly. At least I cannot find a pattern.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .