I have developped a apex trigger on FeedItem after insert. The purpose is to append an hashtag to the body of the post when certain criteria are met. Everything works very well except that any mention in the body of the post becomes plain text. Existing hashtags and the one I append are treated like hashtags.
I type the following post text
This is a post for @[Derek Hughes] to read.
Without the trigger in operation this creates a post with a proper mention of Derek Hughes (hyperlinked) and shows up on my Chatter Feed:
This is a post for Derek Hughes to read.
With the trigger this creates a post like this:
This is a post for @Derek Hughes to read. I added this #tag in my trigger."
Where the @Derek Hughes is plain text (but wiht out the square brackets) but the #tag is a proper post hashtag (hyperlinked)
The simplified code is as follows (it appends the tag to all posts and exhibits the problem):
trigger FeedItemTagger on FeedItem (before insert) {
for (FeedItem fi : trigger.new) {
fi.body = fi.body + ' I added this #tag in my trigger.';
}
}
Has anyone tried something like this before?
Any ideas on how to prevent the @ mentions being converted into text.
Thanks Derek