You need to sign in to do that
Don't have an account?
Hermann Oure 6
Apex Syntax Error
Hello,
I have created an Apex class to count the number of interactions between the customer and the team when Feed Item Type = 'TextPost' or 'EmailMessageEvent'
My custom field "All Users Feed Count" increments correctly when a feed item Text Post is created but it doesn't increment for the Email Feed.
Could someone help?
Thanks.
here is my code:
I have created an Apex class to count the number of interactions between the customer and the team when Feed Item Type = 'TextPost' or 'EmailMessageEvent'
My custom field "All Users Feed Count" increments correctly when a feed item Text Post is created but it doesn't increment for the Email Feed.
Could someone help?
Thanks.
here is my code:
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; } } } } }
I found the below link where in it is mentioned as of how to count the messages and the email count please have a look at the article I think it would be useful for your scenario.
>> https://help.salesforce.com/articleView?id=000334053&type=1&mode=1
In case if this was helpful in your scenario I would request you to please close the thread and mark this as best answer so that it can be useful for others in the future and also help in keeping our community clean.
Regards,
Anutej