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

Record feed doesn't update on Event creation via trigger

$
0
0

I'm trying to get the record feed of my leads to update when I create an event with an after update trigger, it's not working. When I create the event manually the feed gets updated, but not when it's created with the trigger, any ideas ?Here's my code:

List<Event> tourEvents = new List<Event>();    List<FeedItem> chatterPosts = new List<FeedItem>();    List<ID> leadsWithOldEvents = new List<ID>();    for(Lead l: leads){        ID currentID = l.ID;        if(l.recordTypeId == LJLeadId){            Lead oldLead;            for(Lead previous: old){                if(previous.ID == currentID){                    oldLead = previous;                    if(oldLead.Tour_Date__c!=null && (l.Tour_Date__c<>oldLead.Tour_Date__c || l.Tour_Date__c==null)){                        leadsWithOldEvents.add(l.ID);                    }                }            }        }    }    List<Event> oldEvents = [SELECT ID FROM Event WHERE (WHOID IN:leadsWithOldEvents AND Subject='Tour')];    delete oldEvents;    for(Lead l: leads){        if(l.Tour_Date__c!=null){            Event e = new Event(WHOID=l.ID, Subject='Tour',            ActivityDateTime = l.Tour_Date__c,            DurationInMinutes = 120);            tourEvents.add(e);            FeedItem fi = new FeedItem(Type='ActivityEvent', ParentId=l.Id, Status='Published');            chatterPosts.add(fi);        }    }    insert tourEvents;    insert chatterPosts;}

Thank you!


Viewing all articles
Browse latest Browse all 68

Trending Articles



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