You need to sign in to do that
Don't have an account?
Charlotte Holden
Assistance with Email Alert for the FeedComment Trigger
Hi, I am not a Developer and do not know how to write Apex Code, so I am looking for some help, as to how I adapt the below existing code for the FeedComment Trigger so we automatically send an email alert to the case owner when a new FeedComment record is created.
trigger FeedComment_UpdateCaseStatus on FeedComment(after insert, after update){
List<Case> CasesToUpdate = new List<case>();
List<id> UserList = new List<ID>();
List<Id> FeedItemList = new List<id>();
String RecordTypeId = String.valueof([SELECT ID FROM Profile WHERE Name = 'Symatrix Community Plus User'].Id);
for(FeedComment fc: Trigger.New) {
feedItemList.add(fc.FeedItemId);
UserList.add(fc.InsertedById);
}
Map<Id, FeedItem> FeedMap = new Map<id, FeedItem>([select id,InsertedById,Visibility from feedItem where Id IN :FeedItemList]);
Map<Id, User> UserMap = new Map<Id, User>([select id, ProfileId, usertype, name from user where ID IN :UserList]);
for(FeedComment fc: Trigger.New){
if (FeedMap != null && FeedMap.containsKey(fc.feedItemId) && fc.ParentId.getSObjectType() == Case.SObjectType) {
case cs = new case();
cs.id = fc.ParentId;
if (UserInfo.getProfileId() == RecordTypeId && String.valueof(fc.ParentId).substring(0,3) == '500' && cs.status != 'Open') {
cs.status = 'Open';
}
cs.Last_Chatter_Feed_Timestamp__c = date.today();
CasesToUpdate.add(cs);
}
}
if (CasesToUpdate != null && CasesToUpdate.size() > 0) {
update CasesToUpdate;
}
}
trigger FeedComment_UpdateCaseStatus on FeedComment(after insert, after update){
List<Case> CasesToUpdate = new List<case>();
List<id> UserList = new List<ID>();
List<Id> FeedItemList = new List<id>();
String RecordTypeId = String.valueof([SELECT ID FROM Profile WHERE Name = 'Symatrix Community Plus User'].Id);
for(FeedComment fc: Trigger.New) {
feedItemList.add(fc.FeedItemId);
UserList.add(fc.InsertedById);
}
Map<Id, FeedItem> FeedMap = new Map<id, FeedItem>([select id,InsertedById,Visibility from feedItem where Id IN :FeedItemList]);
Map<Id, User> UserMap = new Map<Id, User>([select id, ProfileId, usertype, name from user where ID IN :UserList]);
for(FeedComment fc: Trigger.New){
if (FeedMap != null && FeedMap.containsKey(fc.feedItemId) && fc.ParentId.getSObjectType() == Case.SObjectType) {
case cs = new case();
cs.id = fc.ParentId;
if (UserInfo.getProfileId() == RecordTypeId && String.valueof(fc.ParentId).substring(0,3) == '500' && cs.status != 'Open') {
cs.status = 'Open';
}
cs.Last_Chatter_Feed_Timestamp__c = date.today();
CasesToUpdate.add(cs);
}
}
if (CasesToUpdate != null && CasesToUpdate.size() > 0) {
update CasesToUpdate;
}
}
You can turn on email from Chatter for all users by going to Setup>Build>Customise>Chatter>Email Settings and then tick the Allow Emails and/or Allow Email Replies.
Once enabled this setting, case owner will get the notification of feed comments.
If this helps, Please mark it as best answer.
Thanks!!