I have a trigger (Before Insert) on FeedItem that needs to modify a post by substituting certain words with replacement values, by updating FeedItem.Body. This works fine, except that @mentions are lost - the post looks like plain text; links to mentioned users are lost.

I found this similar question but the proposed solution was to use ConnectApi to post. The problem is, I'm not creating a new post directly, but changing a post in a trigger. Is it possible to preserve formatting while modifying the FeedItem SObject?

1 Answer 1


Unfortunately, when you modify FeedItem.Body in a trigger, there's currently no way to preserve the @-mentions in the body. This is a known limitation, which will be added to the documentation shortly.

UPDATE: There's now a roundabout way to preserve @mentions in FeedItem and FeedComment triggers if you turn on the feature to edit your Chatter posts and enable it for everyone who will be posting. See the blog post on Preserving Mentions in Triggers.


You must log in to answer this question.

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