You need to sign in to do that
Don't have an account?
clouduser
any idea to share the record to the user whom we mentioned @someone in the chatter posting.
Any thoughts to share the record to the user whom we mentioned @someone in the chatter posting. I know we can do somethng with the feeditem trigger.
thanks for the suggestion. I am able to achieve this by writing a trigger on feeditem using connectapi apex classes. find the sample code to retrieve the user ids of @mentioned users.
ConnectApi.FeedItem feedItem = ConnectApi.ChatterFeeds.getFeedItem(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.user.id);
}
}
All Answers
One issue with this approach is, if there are 2 users with the same name, you can not identify which one was in @mention.
thanks for the suggestion. I am able to achieve this by writing a trigger on feeditem using connectapi apex classes. find the sample code to retrieve the user ids of @mentioned users.
ConnectApi.FeedItem feedItem = ConnectApi.ChatterFeeds.getFeedItem(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.user.id);
}
}
String communityId = null;
refer the API documentation for more details..
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_connect_api.htm