You need to sign in to do that
Don't have an account?
Trigger Help - Update Case Status based on Feed Comment
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)
I think you can achieve by trigger.
Reference: https://salesforce.stackexchange.com/questions/30730/trigger-update-case-field-based-on-feeditem
Thanks,
This worked for me ... You can try this .. Let me know if you have any doubt.
Trigger:
trigger SimpleTrigger on FeedItem (after insert) {
List<Id> caseIds = new List<Id>();
List<Case> updateCase = new List<Case>();
for (FeedItem newFeed : Trigger.new) {
if (newFeed.ParentId.getSObjectType() == Case.SObjectType) {
caseIds.add(newfeed.ParentId);
Case myCase = [Select Id, AccountId, Status FROM Case WHERE Id IN :caseIds];
updateCase.add(mycase);
for(Case c : updateCase){
if(c.Status != 'Working' && c.AccountId != Null){
c.Status = 'Working';
}
}
}
}
update updateCase;
}
hey @kcrock88,
Regarding your second bullet point: "With Case Feed Layout - we were able to use Flow and Process Builder to replicate this action for a New Case Feed Item". Did you create a process builder on the feed item object? Whereas you needed a trigger for a case post comment?
trigger FeedThis on FeedComment(after insert, after update){
List<Case> updates = new List<case>();
List<id> userList = new List<ID>();
List<Id> feedItemList = new List<id>();
for(FeedComment fc: trigger.new){
feedItemList.add(fc.FeedItemId);
userList.add(fc.InsertedById);
}
Map<Id, FeedItem> feedMap = new Map<id, FeedItem>([select id,InsertedById,Visibility from feedItem where Id IN :feedItemList]);
Map<Id, User> userMap = new Map<Id, User>([select id, usertype, name from user where ID IN :userList]);
for(FeedComment fc: trigger.new){
if (feedMap != null && feedMap.containsKey(fc.feedItemId) && fc.ParentId.getSObjectType() == Case.SObjectType) {
updates.add(new Case(
Id = fc.ParentId,
Status = 'Open'
));
}
}
if(updates != null && updates.size() > 0)
update updates;
}