Have two custom objects, Master and Child. Child has a lookup to Master.
Trigger is saving, but not firing when I update the Child:
trigger updateMasterName on Child_Custom__c (before insert, before update){
list<Id> masIds = new list<Id>();
list<Master_Custom__c> masters = new list<Master_Custom__c>();
for(Child_Custom__c cc:trigger.new){
masIds.add(cc.Master_Custom__r.id);
}
for(Master_Custom__c mas:[select Id from Master_Custom__c where Master_Custom__c.id IN :masIds]){
for(Child_Custom__c ccc : trigger.new){
if(ccc.Name == 'aaa'){
ccc.Master_Custom__r.Name ='Wow this worked';
masters.add(mas);
}
}
}
update masters;
}