Unable to get values from __r Reference in a trigger

Unable to get values from __r Reference in a trigger

In a trigger we cannot get parent record or child record values using __r notation.

The work around for this is we have to get the parent records or child records using the trigger.newMap.keySet().

Sample Code:

List<ParentObject> List = [SELECT Name, Id FROM ChildRecord WHERE ParentObject__c IN : trigger.newMap.keySet();

Leave a Reply