Menu Close
    Hire us Request quote Reading list Switch to dark mode

    How to post to chatter feed from APEX

    Most of the Organisation using Salesforce must be knowing about Chatter. For those people who might not be having idea about chatter, in the easiest words we can say that, it is the social network of any Salesforce org. We can post quotes, images, updates, and much more. To enable chatter all we have to do is go to the Setup|Customize|Chatter|Chatter Settings and enable chatter. After that a new chatter tab will be visible in specific apps. However someone might be having a specific requirement about posting data on chatter from APEX code. That is what I’ll be discussing about, how to post to chatter from apex.

    Apex Code

    As you can see here we have used an object of the FeedItem class, which is used to post data to chatter. All we have to do is enter the post body and parentId, and then insert the post. You can also provide your own id to the parentId which will result in the post being posted to your own profile.

    VisualForce Code

    In the Visualforce Code we have just got the data that we want to create a post on chatter. Once after entering the data, click on the post button and then quickly move to the chatter tab to see the updates.


    The output of my code will be as follows:


    That’s all about creating a post on chatter through APEX, for any further queries feel free to add a ticket at:

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .

    Or let us know your views on how to make this code better, in comments section below.

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again

    Table of Content

    Hide Index