Activity Forums Salesforce® Discussions How to chatter post through Apex??

  • Surbhi

    Member
    May 25, 2016 at 12:51 pm

    Hi Himanshu,

    Please find the below code for chatter post through apex:

    //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;

    Hope this will help you.

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos