You need to sign in to do that
Don't have an account?
Jayesh Deo 2
When child obj fields are updated parent obj field gets auto updated How to collect parent obj records associated with child obj via lookup relation for After Update trigger?
Hiring_Manager__c =Parent Object
Recruiter__c= Child Object (Lookup relation)
I am trying to automatically update parent record fields when child record gets updated by using After Update trigger but I got below error in SOQL query.
List <Hiring_Manager__C> GetHiringManagersList=[select id,name, Location__c, Phone__C, Email__c from Hiring_manager__C
where recruiter__r.id IN:lstrecs.keyset()];
ERROR=Didn't understand relationship 'recruiter__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
I am using Map collection here. Which will be best suitable type of collection (List/MAp)in such scenarios?
Recruiter__c= Child Object (Lookup relation)
I am trying to automatically update parent record fields when child record gets updated by using After Update trigger but I got below error in SOQL query.
List <Hiring_Manager__C> GetHiringManagersList=[select id,name, Location__c, Phone__C, Email__c from Hiring_manager__C
where recruiter__r.id IN:lstrecs.keyset()];
ERROR=Didn't understand relationship 'recruiter__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
I am using Map collection here. Which will be best suitable type of collection (List/MAp)in such scenarios?
Try using below soql query: It queries the Hiring_Manager__c parent records associated with the Recruiter__c child records contained in the lstrecs map.
In your case, as you are associating child records with parent records, so you can use a map . You can populate the map with queried parent records using their IDs as keys and then use this map to associate child records with their respective parent records.
Related:
https://developer.salesforce.com/forums/?id=906F000000092MLIAY
https://intellipaat.com/blog/collection-in-salesforce/
https://shreysharma.com/child-to-parent-relationship/
https://www.salesforcetutorial.com/relationship-queries-salesforce/
If this information helps, please mark the answer as best. Thank you