Quantcast
Channel: Active questions tagged chatter-feed - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 191

caused by: System.NoAccessException: Class.ConnectApi.ChatterFeeds.postFeedElementBatch: line 1254, column 1 [closed]

$
0
0

We are running into below issue. can anyone please help me ?

Error Lines:

Class.ConnectApi.ChatterFeeds.postFeedElementBatch: line 1254, column 1 Class.ChatterFeedUtil.notifyRecordOwners: line 36, column 1 Class.OpportunityTriggerHandler.OnAfterUpdate: line 844, column 1 Trigger.OpportunityTrigger: line 36, column 1

***TriggerHandler Class***

System.debug('### Lead Assignment Notification - ' + recordOwnerMap);
        if (!communities.isEmpty() && !recordOwnerMap.isEmpty() && !isNotified) {
            // Id.valueOf('0DB900000004CxwGAE')
            //ChatterFeedUtil.notifyRecordOwners(communities.get(0).Id, recordOwnerMap, ' ' + Label.Lead_Notif_New_Assignment);
            if(!recordOwnerForNotifyMap.isEmpty()){
                ChatterFeedUtil.notifyRecordOwners(communities.get(0).Id, recordOwnerForNotifyMap, ' ' + Label.Lead_Notif_New_Assignment);                
            }
            isNotified = true;
        }

Chatter feed util class:

public static void notifyRecordOwners(Id networkId, Map<Id, Id> recordToUserMap, Map<Id, String> recordToMessageMap) {
    List<List<ConnectApi.BatchInput>> batchList = new List<List<ConnectApi.BatchInput>>();
    List<ConnectApi.BatchInput> batches = new List<ConnectApi.BatchInput>();

    for (Id recordId : recordToUserMap.keySet()) {
        ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
        ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
        ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
        ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

        messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();

        mentionSegmentInput.id = recordToUserMap.get(recordId); // User ID
        messageBodyInput.messageSegments.add(mentionSegmentInput);

        textSegmentInput.text = recordToMessageMap.get(recordId);
        messageBodyInput.messageSegments.add(textSegmentInput);

        feedItemInput.body = messageBodyInput;
        feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
        feedItemInput.subjectId = recordId; // Record ID
        feedItemInput.visibility = **ConnectApi.FeedItemVisibilityType.AllUsers;
        batches.add(new ConnectApi.BatchInput(feedItemInput));**

        if (batches.size() == 500) {
            batchList.add(batches);
            batches.clear();
        }
    }

Viewing all articles
Browse latest Browse all 191

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>