+ Start a Discussion

Trigger on child case to update parent case

Hi Can you help with the trigger.


I want to update the status field on parent case when child case status is updated? Is it possible. Can you send me the sample for that?


I have seen sample trigger the other way round for updating child case when parent case is updated.




Any help with be appreciated.




Best Answer chosen by Admin (Salesforce Developers) 

Try smth like this:


trigger CaseTest on Case (after update) {
Map<Id, Case> mParCase2upd = new Map<Id, Case>();
for(Case c1 : trigger.new){
if(c1.ParentId != null && c1.Status != trigger.oldMap.get(c1.Id).Status){
mParCase2upd.put(c1.ParentId, new Case(Id = c1.ParentId, Status = c1.Status));
if(mParCase2upd.values() != null && mParCase2upd.values().size() > 0){
update mParCase2upd.values();



Trigger works only for updates (as you asked) so newly created child case will not update the parent. The code is simplified however should work, unless You have some additional validation which requires some addiitonal data when statuses are changed...


Hope it will help ya.


Best regards