Quantcast
Channel: Active questions tagged feeditem+chatter - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 68

Attachments in FeedItem After Insert Trigger

$
0
0

I'm trying to get the attachments from a FeedItem after insert trigger, but it does not return all the associated attachments. I understand attachments are inserted after the FeedItem is inserted (ref.), but I am able to get the first attachment (and only the first attachment) in the after insert trigger. Is there any way to get all related attachments of a FeedItem in an after insert trigger?

On the high level - I am trying to convert regular posts to a specific CollaborationGroup to a Question, which I am handling with after insert trigger. While the post gets converted to Question, I am unable to pass its attachments. Any suggestions?

EDIT - Added code shippet.

Trigger:

trigger FeedItemTrigger on FeedItem (after insert) {
    List<Id> feedItemIds = new List<Id>();
    for(FeedItem fi : Trigger.New){
        feedItemIds.add(fi.Id);
    }
    List<FeedAttachment> attachments =  [SELECT Id, Title, Type, FeedEntityId FROM FeedAttachment WHERE FeedEntityId IN :feedItemIds];
    System.debug('attachments count :: '+attachments.size());
}

Chatter Post: Chatter Post

This gives gets me only one attachment from the FeedItem.


Viewing all articles
Browse latest Browse all 68

Latest Images

Trending Articles



Latest Images