I want to add Chatter feeds from Trigger and obviously I am going to implement this as Bulkified.

I have data in the following format.

Public Class ChatterFeedInfo
    public Id usermentionId {get;set;} // user records to which chatter feed will be @mentioned [@John Doe]
    public Id recordId {get;set;} // parent record id
    public String body {get;set;} // feed body
    public Id chatterGroupId {get;set;} // if not null  post this feed to Chatter Group

I get List<ChatterFeedInfo> chatterFeeds in my trigger but not sure how to implement this with 'Chatter in Apex'.

Please suggest.


You can bulk insert to FeedItem directly in Apex, but unfortunately you cannot perform an @mention this way. Also, techtrekker is right about using the Connect API, it doesn't support multiple inserts at once.

Tell us a little about your implementation. You might be able to do this from another perspective. You mentioned doing this from a trigger. Is the trigger being fired from insert/update from custom code (i.e. VF/apex) or some other mechanism?

  • Not sure what the downvote was about. Only reason I didn't ask the question in a comment was because at the time I had no comment ability. – drakored Jun 11 '13 at 18:11

I am running into the same issue.

Similar to what you are doing, I have a pod data class to wrap Feed Items I want to post. I also created a shadow object, e.g. Chatter_Feed_Info__c.

In my trigger, I check how many DML statements remain. If I cannot insert all my Feed Items one at a time under the limit, I bulk create the shadow objects instead. Then I call a batch that posts the shadow Feed Items to Chatter 150 at a time.

Disclaimer: I haven't gotten to testing yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.