function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jayaram reddyjayaram reddy 

fetch opportunity feeditem using apex

How to fetch opportunity post chatter feedItem in the visualforce and apex.

Thanks,
Jayarami reddy.
Deepali KulshresthaDeepali Kulshrestha
Hi jayaram,
Greetings to you!



try this code to solve your problem.


How to create chatter post using Apex in Trigger or Controller?
============================================================
Sample Code:

//Adding a Text post
FeedItem post = new FeedItem();
post.ParentId = oId; //eg. Opportunity id, custom object id..
post.Body = 'Enter post text here';
insert post;

//Adding a Link post
FeedItem post = new FeedItem();
post.ParentId = oId; // Record Id eg. Opportunity id, custom object id..
post.Body = 'Enter post text here';
post.LinkUrl = 'http://www.infallibletechie.com';
insert post;

//Adding a Content post
FeedItem post = new FeedItem();
post.ParentId = oId; // Record Id eg. Opportunity id, custom object id..
post.Body = 'Enter post text here';
post.ContentData = base64EncodedFileData;
post.ContentFileName = 'infallible.pdf';
insert post;

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.


Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com