function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Justin LonisJustin Lonis 

NEED HELP PLEASE!!!! - Posted last week about a quick trigger and GOT NO RESPONSES!!!!!


can anyone help me create a trigger to get "status" to change values (picklist field) from feed comments?

Just looking to have a status change from "Awaiting Customer Feedback" to "Working" when a Feed Comment post is made: A picture of the example is below. Any help would be appreciated!!!


User-added image


User-added image
James LoghryJames Loghry
First off, "yelling" and using ALL CAPS is not going to get you help any faster.  In fact, it puts most of us off and deters us from answering or trying to help with your questions.

That being said, a good place for you to start would be the Apex Triggers Trailhead module found here: https://developer.salesforce.com/trailhead/module/apex_triggers.  The module lays out how to build and configure a trigger.  As you probably already know, Processes don't fire on the FeedComment object (yet), so you will need a trigger instead of a process for this task.

I'm not going to write the trigger for you, but I will give you a few pointers:
  1. You can likely get by with a before insert trigger here, as you shouldn't need to do anything special with the feed comment's id.
  2. You'll want to iterate through Trigger.new, and check to see if the FeedComment's ParentId field is a Case record.
  3. For number 2, you can use the Id.getSobjectType() method outlined here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_id.htm
  4. Here's another example for dealing with cases and their feed comments in a trigger: http://salesforce.stackexchange.com/questions/53384/how-can-you-ensure-a-feedcomment-trigger-only-applies-for-cases
  5. Once you determine it's a Case FeedComment, then I would add the Id to a set of case ids.
  6. Outside of the for loop, you'd then query for all case ids in the set of case ids in step 5 AND having a status of "Awaiting Customer Feedback".
  7. Then update those case records to a Working status.