• Julie ODonnell 6
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 4
    Replies
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;
}
Hello! Hoping someone can help - we recently migrated from Case Comments to Case Feed Layouts within our community. 
  • When the "Case Status" field is in "Awaiting Customer Feedback" - we previously had workflow rules to kick the Case Status back to "Working" when a customer posted a comment
  • With Case Feed Layout - we were able to use Flow and Process Builder to replicate this action for a New Case Feed Item
  • With Case Feed Layout - we are struggling to replicate this functionality for a new Case Post Comment (customer posts a Feed Item Comment rather than a new feed Item)
What would be the best way to accomplish this? Not an Apex Developer by trade, but hoping this can be done with a relatively simple trigger - any feedback would be appreciated!
User-added image

 
Hello! Hoping someone can help - we recently migrated from Case Comments to Case Feed Layouts within our community. 
  • When the "Case Status" field is in "Awaiting Customer Feedback" - we previously had workflow rules to kick the Case Status back to "Working" when a customer posted a comment
  • With Case Feed Layout - we were able to use Flow and Process Builder to replicate this action for a New Case Feed Item
  • With Case Feed Layout - we are struggling to replicate this functionality for a new Case Post Comment (customer posts a Feed Item Comment rather than a new feed Item)
What would be the best way to accomplish this? Not an Apex Developer by trade, but hoping this can be done with a relatively simple trigger - any feedback would be appreciated!
User-added image