0

When i try to fetch announcements from feedItem trigger it returns null always, is there anything i'm missing

trigger Email_Feed_Trigger on FeedItem (after insert) {   
Set<Id> myfeed=new set<Id>();

for(FeedItem item : Trigger.New)
{
    myfeed.add(item.Id);
    }
    List<Announcement> lst=  [select id,SendEmails,FeedItemId,ParentId,createddate from Announcement where FeedItemId IN:myfeed];
   //lst is always blank
    system.debug(lst);
}

enter image description here

1 Answer 1

0

You will not get the announcement record because the- announcement has a relation to feed item which is required field on the announcement object. So, once feed item gets inserted then only announcement records will get inserted.

Understand the whole process with this: Creating a group announcement is a three-step process.

  1. Use the FeedItem object to create a text post with the announcement’s content. Use the CollaborationGroup record you want to post the announcement to as the parent of this feed item.
  2. Next, use the feed item ID and an expiration date to create the announcement record.
  3. Finally, update the AnnouncementId field in the CollaborationGroup record with the ID of the announcement you created.

Note:- You cannot write a trigger on Announcement object.

1
  • You can see i'm using after insert trigger? so announcement record must be available at that point, i know we cant write trigger on Announcement object thats why i'm doing it on feedItem
    – Ramesh
    Commented Jul 12, 2019 at 13:36

You must log in to answer this question.

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