Please find my code here.
trigger PM1 on Account (after update) {
List<Product_Metrics_vod__c> toDelete = new List<Product_Metrics_vod__c>();
set<id> accsWithChangedRestrictions = new set<id>();
for(Account acc : trigger.new){
//if(acc.Restricted_Products_vod__c != trigger.oldMap.get(acc.id).Restricted_Products_vod__c)
accsWithChangedRestrictions.add(acc.id);
}
list<Account> accs = [select Restricted_Products_vod__c,id, (select Products_vod__r.Name from Product_Metrics_vod__r) from Account where id in :accsWithChangedRestrictions];
for(Account acc : accs){
for(Product_Metrics_vod__c av : acc){
if(acc.Restricted_Products_vod__c.contains(av.Products_vod__r.Name)){
//found a match
toDelete.add(av);
}
}
}
delete toDelete;
}
Error: Compile Error: Loop must iterate over a collection type: SOBJECT:Account at line 12 column 41