I'm sure this has been addressed before but I can't seem to find the answer. In a trigger on a record, aside from the actual fields on the record, what do I have access to? The parent info? that record's children? Do you just add the fields by re querying in your handler?
You only have access to fields that are on the object. If you want parent or child data, you have to query for it. In either case, you can query at any of the three levels. For example, if you have
Grandparent objects and you are in the
List<Grandparent__c> parents = [ SELECT Name FROM Grandparent__c WHERE Id IN :someCollection ]; List<Parent__c> contextRecords = [ SELECT Grandparent__r.Name, (SELECT Name FROM Children__r) FROM Parent__c WHERE Id IN :trigger.newMap.keySet() ]; List<Child__c> children = [ SELECT Name FROM Child__c WHERE Parent__c IN :trigger.newMap.keySet() ];