Skip to main content
I wrote (with the help of the community!) the following Apex code to update a case field any time someone posts to the case feed.  The issue I have now is that if someone replies to the feed comment instead of the feed item, my fields don't update.  Can someone help me to modify the below to achieve my desired result?

 

 

trigger UpdateCaseCommentFields on FeedItem (after insert, after update) {

List<Case> updates = new List<Case>();

for (FeedItem fi : Trigger.new) {

if (fi.ParentId.getSObjectType() == Case.SObjectType && fi.Visibility == 'InternalUsers') {

updates.add(new Case(

Id = fi.ParentId,

Last_Internal_Comment__c = fi.Body

));

}

else if (fi.ParentId.getSObjectType() == Case.SObjectType && fi.Visibility != 'InternalUsers') {

updates.add(new Case(

Id = fi.ParentId,

Last_External_Comment__c = fi.Body

));

}

}

update updates;

}

 

 
1 risposta