Skip to main content
Shaun Bailey (defi SOLUTIONS) ha fatto una domanda in #Apex
Hello (Developer) World!

I wrote (with the help of the community!) the following Apex code to update a case field anytime 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 or add to 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;

}

12 risposte
  1. 10 ago 2016, 17:22
    Hi Bailey,

    My bad, please replace below line at line 7:

    List<id> userList = new List<ID>();

    Please try now, let me know if you still face issues on this.

    Thanks,

    Gaurav

    Email: gauravgarg.nmims@gmail.com