2

I am inserting the chatter feed using Apex but @mentioned user is not getting the notification. @mentioned user is different than the user who is creating that feed.

What all could be the possible scenarios where @mentioned user (via apex) can not get notifications.

Thanks for the response

3 Answers 3

2

You can do that via the ConnectAPI in Apex...it can be a bit complicated to code it, but thankfully, the nice folks on the team at SFDC built a helper class - you can see it here.

So to post a Happy Birthday message with an @mention to the user would look something like this if you have the above class installed:

String sText = 'Happy Birthday {005E0000005LZXh}!';
ConnectApi.FeedItem fi = ConnectApiHelper.postFeedItemWithMentions(null, 'me', sText);

The class parses for the {userId} syntax, and converts to be an @mention. I wrote a blog post about here which has some more context/examples

1

Know that is few years ago, but recently I had the same/similar issue. Writing to chatter from apex with ConnectAPI and while admin did receive notifications, user with lower profiles didn't. Made few tests and finally it solved by providing the other profiles View All access on the object that I'm posing. Seems strange, but it does solve the issue for me. Double verified it by removing the View All access and notice that again the users are not getting the notifications.

-1

Arjun, unfortunately you cannot make use of mentions when creating Chatter feed items and comments using Apex. The only way to tap the functionality with mentions and topics is to use the Chatter REST API. Instead of inserting FeedItem or FeedComment records in the trigger, try making a callout to the REST API.

You must log in to answer this question.

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