I have a trigger on a custom object trigger cTrigger on C__c(after insert, after update) that works correctly when a new C__c is created. C__c also has Chatter posts enabled and I am trying to write a trigger that runs when a new Chatter post is made on any specific C__c object. Any help is appreciated. I have searched through the documentation and triggers of this type are not mentioned.

  • Have you seen documentation on chatter objects here & documentation on feed item?
    – Jayant Das
    Commented May 4, 2018 at 21:17
  • That's helpful but I don't understand how you can use the example to only work on a specific kind of object if you use: trigger FeedItemTrigger on FeedItem (after update) { List<FeedAttachment> attachments = [SELECT Id, Title, Type, FeedEntityId FROM FeedAttachment WHERE FeedEntityId IN :Trigger.new ]; for (FeedAttachment attachment : attachments) { System.debug(attachment.Type); } } How do only get the posts related C__c?
    – Subito
    Commented May 4, 2018 at 21:30
  • Please do not post code in comments. Have your original post edited for that purpose. As for your question, I have provided an answer, which will help you to take it from there.
    – Jayant Das
    Commented May 4, 2018 at 21:31

1 Answer 1


Assuming you want to write trigger on Chatter Posts made on specific records, what you want is to write a trigger on FeedItem object. You can find more on the documentation here.

FeedItem represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts.

The Record Id of the C__c record where this post is being made will be available in the feed item trigger by accessing the ParentId field. You can process anything further related to the original record once you capture the parent id.

Parent Id of the Feed Item is described in the documentation as:

ID of the object type to which the FeedItem object is related. For example, set this field to a UserId to post to someone’s profile feed, or an AccountId to post to a specific account.

Also refer to the considerations while writing trigger on chatter objects, which can be found at this link.

  • Thank you for your reply! I was able to use the documentation to successfully create the trigger on 'FeedItem'! If I may ask, I have a follow-up question: If I wanted to create a trigger for when someone comments on a created 'C__c' Chatter Post would I still need to use 'FeedItem'?
    – Subito
    Commented May 7, 2018 at 15:01
  • @Subito - that would be a FeedComment object
    – Jayant Das
    Commented May 7, 2018 at 15:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .