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
Vivek KidambiVivek Kidambi 

Chatter - New Contact is created on Account

I need a chatter feed on account whenever a new contact is created for an account. Can i do this using OOTB?
KaranrajKaranraj
Currently you can't create object specific chatter post using Process builder. Here is the simple trigger code, which will create chatter post on Account record, when new contact record is created
 
trigger chatterPostonAccount on Contact(After insert){
 List<FeedItem> posts = new List<FeedItem>();
 for(Contact con: Trigger.New){
    if(con.AccountId != null){
        FeedItem post = new FeedItem();
        Post.ParentId = con.AccountId;
        post.body = 'New contact created';
        posts.add(post);
    }
 }
 insert posts;
}