You need to sign in to do that
Don't have an account?
Richard Cave09035942158259942
find out who @mention someone in chatter feed
I have a trigger on the feed Item, I want to be able to find out in that feed if someone has @mention someone. I did think of searching through the body of the feed item to search for @[firstname lastname] but they have seemed to have removed the brackets from the feeditem body.
Are the @mentioned stored in any salesforce table?
Thanks.
Are the @mentioned stored in any salesforce table?
Thanks.
In order to find out if a user is actually @mentioned, you may have to use the Chatter API, as mentioned here: http://salesforce.stackexchange.com/questions/10047/retrieve-userid-of-mention-user-from-chatter-post-in-apex
All Answers
In order to find out if a user is actually @mentioned, you may have to use the Chatter API, as mentioned here: http://salesforce.stackexchange.com/questions/10047/retrieve-userid-of-mention-user-from-chatter-post-in-apex
String communityId = null;
String feedItemId = 'feed id';
ConnectApi.FeedElement feedItem = ConnectApi.ChatterFeeds.getFeedElement(communityId, feedItemId);
List<ConnectApi.MessageSegment> messageSegments = feedItem.body.messageSegments;
for (ConnectApi.MessageSegment messageSegment : messageSegments) {
if (messageSegment instanceof ConnectApi.MentionSegment) {
ConnectApi.MentionSegment mentionSegment = (ConnectApi.MentionSegment) messageSegment;
System.debug('Mentioned user name: ' + mentionSegment.name);
System.debug('Mentioned user id: ' + mentionSegment.record);
}