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
Dee Dee AaronDee Dee Aaron 

Help to write trigger.

Hi. I am hoping to use a trigger like the ones in this example thread, but I need help to write it:
https://developer.salesforce.com/forums/?id=906F0000000D8WtIAK

I have a custom object called “Sales Engineering Request” and there’s a chatter feed on this object.
I have a custom “status” field with a picklist and I want the value to be updated based on the last Feed Comment that was made.


Criteria:
If status is in “Pending Review" or "Awaiting Reply from Net Planning" or "Awaiting Reply from Sales”, then update based on the last commenter.
If the last person who commented is part of the Net Planning Department (User Profile ID: 00e3t000001PTFmFFO), update the status to: “Awaiting Reply from Sales”
If the last person who commented is NOT part of the Net Planning Department (Does NOT have User Profile ID: 00e3t000001PTFmFFO), update the status to: “Awaiting Reply from Net Planning”

Note: I was able to get this to work using a process builder for the feeditem, but the feedcomment is not available from Workflows, Process Builders, or Flows, so I believe a trigger is the best path.

Thank you for your help.
ShirishaShirisha (Salesforce Developers) 
Hi Aaron,

Greetings!

I would suggest you to initiate the trigger by replacing the Object and the field instead of the Case with the sample code given in the link:

https://developer.salesforce.com/forums/?id=906F0000000D8WtIAK

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri