You need to sign in to do that
Don't have an account?
AB003
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.
http://wiki.developerforce.com/page/Synchronize_A_Parent_Case's_Status_To_The_Status_Of_Its_Children
Any help with be appreciated.
Thanks
Abi
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