Getting some odd results from a query in a before
trigger context
My Account object has a lookup to a object called Region__c
. Region__c
has a lookup to Division__c
.
When I try to query the Division from the Account, it instead only returns the region id:
List<Account> accs = [SELECT Region__r.Division__c
FROM Account WHERE Id IN :Trigger.NewMap.Keyset()];
System.debug(accs);
(Account:{Id=0014C000008cL2LQAU, Name=asdas, OwnerId=0053000000BPS4DAAX, Region__c=a0k30000000QnH3AAK})
The only thing I can think of is this is a permissions issue (still would seem like weird behavior), but I've checked Object, FLS, used without sharing
, and not to mention I'm running as an admin user.
What am I missing?
Update:
If I query the Division directly from the Region it works fine:
for(Account acc : Trigger.new){
System.debug([SELECT Division__c FROM Region__c WHERE Id = :acc.Region__c]);
}
(Region__c:{Division__c=a1W3A000001dfIGUAY, Id=a0k30000000QnH3AAK})