Connect API : Post Feed to chatter with @mention using Apex
This post helps you know how to post feed to chatter with @mention in Apex.
The ConnectApi namespace (also called Chatter in Apex) provides classes for accessing the same data available in Chatter REST API. Use Chatter in Apex to create custom Chatter experiences in Salesforce.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void postfeed(){ | |
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput(); | |
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput(); | |
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput(); | |
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput(); | |
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>(); | |
/*Specify the user id for @mention. You can create multiple ConnectApi.MentionSegmentInput if | |
there are multiple users. | |
*/ | |
mentionSegmentInput.id = '00528000001BOFC'; | |
messageBodyInput.messageSegments.add(mentionSegmentInput); | |
textSegmentInput.text = 'Could you take a look?'; | |
messageBodyInput.messageSegments.add(textSegmentInput); | |
feedItemInput.body = messageBodyInput; | |
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem; | |
//SubjectId indicates to which record this feed item will be tagged to. | |
feedItemInput.subjectId = '00128000002LcDW'; | |
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(null,feedItemInput ); | |
} |
Great blog. It is simply innovative and useful.
ReplyDeleteIts pretty good and well noted. All your points are very useful.
salesforce training in chennai
salesforce course in chennai
salesforce training institute in chennai
salesforce training in bangalore
salesforce training institute in bangalore
salesforce course in bangalore
This is most informative and also this post most user friendly and super navigation to all posts. Thank you so much for giving this information to me.salesforce developer training in bangalore
ReplyDeleteplease help me writing test class for this
ReplyDelete
ReplyDeleteGreat and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
Salesforce Training | Online Course | Certification in chennai | Salesforce Training | Online Course | Certification in bangalore | Salesforce Training | Online Course | Certification in hyderabad | Salesforce Training | Online Course | Certification in pune
I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site. As a result of checking through the net and meeting techniques that were not productive, Same as your blog I found another one Oracle APEX .Actually I was looking for the same information on internet for Oracle APEX and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.
ReplyDelete