I have written an apex trigger based largely off another answer on here which updates a timestamp field on a case, my question is -- how can I do the update on the field only if a certain user has performed the feedcomment update?
trigger FeedThis on FeedComment(after insert, after update){
List<Case> updates = new List<case>();
List<id> userList = new List<ID>();
List<Id> feedItemList = new List<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, 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) {
updates.add(new Case(
Id = fc.ParentId,
//IF User == A_Elric || User == Ethan_H{
Last_Chatter_Feed_Timestamp__c = System.now()
//}
));
}
}
if(updates != null && updates.size() > 0)
update updates;
}
I threw in some comments to show what I'm trying to do vs what I have implemented.
Thanks,