
Hi Muthu,You can use map collection here to avoid nested loops. Learn about it here (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_maps.htm" target="_blank).
Let me know if you face any issue with this. - thatheraheretrigger caseStatusSync on Case (before update) {
Map<Id, Case> mapCaseToProcess = new Map<Id, Case>();
for(case c : Trigger.new){
if( (c.status != Trigger.oldmap.get(c.id).status)
&&( c.status.containsIgnoreCase('Escalated') || c.status.containsIgnoreCase('Resolved') )
){
mapCaseToProcess.put( c.id, c );
}
}
if( !mapCaseToProcess.values().isEmpty() ){
list<case> childCasesToUpdate = new list<case>();
for(case c: [select id,status,parentid from case where parentid in :mapCaseToProcess.keySet() ] ){
c.status= mapCaseToProcess.get( cs.parentid ).status;
childCasesToUpdate.add(c);
}
if( !childCasesToUpdate.isEmpty() )
update childCasesToUpdate;
}
}