You need to sign in to do that
Don't have an account?
Wes Reed 27
Error: Didn't understand relationship 'EngagementContact__r' in FROM part of query call
I am curious how to resolve this error: Didn't understand relationship 'EngagementContact__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
My goal is to have this trigger perform a rollup summary between to objects based on their 'Lookup Relationship'. Any guidance or advice would be greatly appreciated.
Thanks - Wes
My goal is to have this trigger perform a rollup summary between to objects based on their 'Lookup Relationship'. Any guidance or advice would be greatly appreciated.
Thanks - Wes
trigger IndvidualEngagementScore on EngagementContact__c (after delete, after insert, after update) { Set<id> acctIds = new Set<id>(); List<account> accountsToUpdate = new List<account>(); for (EngagementContact__c item : Trigger.new) acctIds.add(item.Account__c); if (Trigger.isUpdate || Trigger.isDelete) { for (EngagementContact__c item : Trigger.old) acctIds.add(item.Account__c); } Map<id,Account> accoutMap = new Map<id,Account>([select id, Individual_Engagement_Score__c from Account where id IN :acctIds]); for(Account acct : [select Id, Name, Individual_Engagement_Score__c, (select id from EngagementContact__r) from Account where Id IN :acctIds]) { accountMap.get(acct.Id).Individual_Engagement_Score__c = acct.EngagementContacs__r.size(); accountsToUpdate.add(accountMap.get(acct.Id)); } update accountsToUpdate; }
You should use what you set for the 'Child Relationship Name' when you created the field. If you look the field setup for the lookup field on the child object you can see the value you entered for that field. Make sure to append __r to it still.
Please use this "EngagementContacts__r" instead "EngagementContact__r" in query
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
Hey Wes,
Use this : -
Thanks