I have a trigger that I am trying to update the custom object (Share_Reference__c) within the Account object. For some reason my query in List accounts isn't working, saying that it didn't understand the relationship 'Share_References__r'. Any ideas? It should be the child object, like I have it. Thanks!
Trigger
trigger UpdateIsShareRef on Share_Reference__c (after insert, after update, after delete, after undelete) {
Set<ID> accountIDs = new set<ID>();
List<Share_Reference__c> records;
If (trigger.isDelete) {
records = trigger.old;
} else {
records = trigger.new;
}
for (Share_Reference__c record : records) {
accountIds.add(record.Account);
}
**List<Account> accounts = [SELECT Id, is_Share_Ref_USAT__c, is_Share_Ref_Digital__c, (SELECT id, SalesTeam__c FROM Share_References__r) FROM Account WHERE ID IN :accountIds];**
For (Account act : accounts){
act.is_Share_Ref_USAT__c = false;
act.is_Share_Ref_Digital__c = false;
for (Share_Reference__c ref : act.Share_References__r){
if (ref.SalesTeam__c == 'USAT Integrated Brand Sales'){
act.is_Share_Ref_USAT__c = true;
}
if (ref.SalesTeam__c == 'Digital Sales'){
act.is_Share_Ref_Digital__c = true;
}
}
update accounts;
}
}
s
inshare_references__r