I'm getting the following error on the code below.
expecting a semi-colon, found ')'
I have placed comments around the offending block. I know it is the offending block because if I remove it, I have no more errors.
trigger HF_preventECInvoiceDelete on ECInvoice__c (before delete) {
Set<Id> parentWithChildIds = new Set<Id>();
Set<Id> parentIds = new Set<Id>();
for(ECInvoice__c pa : Trigger.Old){
parentIds.add(pa.Id);
}
// error is in this block
for(Payment_received__c Ch = [select id, EC_Invoice_num__c, EC_Invoice_num__r.Id from Payment_received__c where ECInvoice__c =: parentIds]){
parentWithChildIds.add(Ch.EC_Invoice_num__r.Id);
}
// end of block
for(ECInvoice__c pa : Trigger.Old){
if(parentWithChildIds.contains(pa.Id)){
pa.adderror('This guy has Children, You cannot hurt him!');
}
}
}