You need to sign in to do that
Don't have an account?
Hermann Ouré
Count the Number of Email Feed from a Case
Hello,
I would like to create an apex class an the EmailMessage object to count the number of Email Feed on a case.
And then use a trigger.
I have done something similar to count the number of text post on a case but I struggle a bit to do the same for EmailMessage
here is what I have done to count the number of textpost.
Apex class
Thanks
I would like to create an apex class an the EmailMessage object to count the number of Email Feed on a case.
And then use a trigger.
I have done something similar to count the number of text post on a case but I struggle a bit to do the same for EmailMessage
here is what I have done to count the number of textpost.
Apex class
public class FeedItemTriggerHandler { public static void countFeedItem(List<FeedItem> lstFeed){ if(lstFeed.size() > 0){ set<Id> setParentIds = new Set<Id>(); for(FeedItem fd : lstFeed){ setParentIds.add(fd.ParentId); } if(setParentIds.size() > 0){ List<Case> lstCase = [Select caseNumber,All_Users_Feed_Count__c, (Select Id,body,Type,Visibility From Feeds where Type = 'TextPost' OR Type = 'EmailMessageEvent') From Case where Id In : setParentIds]; if(lstCase.size() > 0){ for(Case cs : lstCase){ List<CaseFeed> feeds = cs.feeds; Integer count = 0; for(CaseFeed cf : feeds){ if(cf.Visibility == 'AllUsers'){ count+=1; } } System.debug(feeds.size()); cs.All_Users_Feed_Count__c = count; } update lstCase; } } } } }Trigger
trigger FeedItemTrigger on FeedItem (after insert,before delete) { if(Trigger.isAfter){ if(Trigger.isInsert){ FeedItemTriggerHandler.countFeedItem(Trigger.new); } } else if(Trigger.isBefore){ if(Trigger.isDelete){ FeedItemTriggerHandler.countFeedItem(Trigger.old); } } }Could Someone help to do something similar to count the number of Email feed sent on a case.
Thanks
ease u
cool Download, and Stream Daily South african Podcast, Songs, Fakaza (https://sahiphopza.com/category/download-mp3/), hip-hop, mixtapes, videos & news updated daily on Sahiphopza!!!