ConnectApi.ChatterFeeds Limit handling in trigger

I want my code to be reviewed and please point me the scenarios where it can cause exception.

I have a trigger which modifies the chatter feed on Position__c object,

trigger FeedItemBodyModify on FeedItem (after insert) {

    List fiIds = new List(); 
    for(FeedItem fi :
        if('Position__c' == String.valueOf(fi.ParentId.getSObjectType())){


    if(null != fiIds && fiIds.size() > 0){
        String commID = Network.getNetworkId();
        ConnectApi.BatchResult[] feeds = ConnectApi.ChatterFeeds.getFeedElementBatch(commID, fiIds);

        for (ConnectApi.BatchResult result : feeds) {
            if (result.isSuccess()) {
                Object theResult = result.getResult();
                if (theResult instanceof ConnectApi.FeedItem) {
                    ConnectApi.FeedItem item = (ConnectApi.FeedItem) theResult;   
                    ConnectApi.FeedItemInput input = ConnectApiHelper.createFeedItemInputFromBody(item.body);

                    ConnectApi.TextSegmentInput textInput = new ConnectApi.TextSegmentInput();
                    textInput.text = 'Disclaimer: Modified in a trigger.';

                    ConnectApi.TextSegmentInput lineTextInput = new ConnectApi.TextSegmentInput();
                    lineTextInput.text = '---';

                    ConnectApi.TextSegmentInput blankTextInput = new ConnectApi.TextSegmentInput();
                    blankTextInput.text = ' ';

                    ConnectApi.MarkupBeginSegmentInput markupBeginInput = new ConnectApi.MarkupBeginSegmentInput();
                    markupBeginInput.markupType = ConnectApi.MarkupType.Paragraph;

                    ConnectApi.MarkupEndSegmentInput markupEndInput = new ConnectApi.MarkupEndSegmentInput();
                    markupEndInput.markupType = ConnectApi.MarkupType.Paragraph;



                    ConnectApi.ChatterFeeds.updateFeedElement(commID,, input);


I referred for implementing this.

Q1. What is the exact limit for ConnectApi chatter modification?

Q2. I saw that limits are ‘per-user per-hour’. So how to enable ‘per-user per-hour’ limit or it is by default?

Q3. How should I handle if code runs into limit exception? Because here I am trying to modify a feed posted by user and I don’t think it would be good to mark error to the feed record just because we are unable to update the feed with some extra info.

Q4. If I am integrated with a third party app which on bulk upload generates chatter feed for each object, how should I handle it in trigger without hitting the limits?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Q1: The exact limits aren’t specified, but they’re described generally on the Understanding Limits for ConnectApi Classes doc page.

Q2: The per-user. per-app, per-hour rate limits are the default. You can’t opt out of them.

Q3. You could catch the ConnectApi.RateLimitException and allow the trigger to proceed so that at least the FeedItem gets inserted.

Q4. This is going to be tricky. Currently the ConnectApi.ChatterFeeds.updateFeedElement() method needs to be called for each feed item individually because there’s no batch method available (it would be nice to have an updateFeedElementBatch(), similar to the existing getFeedElementBatch() and postFeedElementBatch() methods). You may need to throttle the bulk upload if that’s an option.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x