You need to sign in to do that
Don't have an account?
path resolves but returns null in apex
Trying to get an email address via User through an object called Community_Visit__c.
InsideSalesperson__c is a lookup(User) field in my custome object.
the above code returns the following debug info.
cv.is=005i0000000jo3XAAQ
cv.is.email=null
if I run this SOQL query in developer console
InsideSalesperson__c = 005i0000000jo3XAAQ
InsideSalesperson__r.Email = mary.k@emaiaddress.com
InsideSalesperson__r.Name = Mary K
so why is it returning null in apex ?
FYI this code is called from a trigger
thanks, Eric J
InsideSalesperson__c is a lookup(User) field in my custome object.
for (Community_Visit__c CV : listCVs){ System.debug('cv.is='+cv.InsideSalesperson__c); System.debug('cv.is.email='+cv.InsideSalesperson__r.email); mail.setReplyTo(CV.InsideSalesperson__r.Email); mail.setSenderDisplayName(CV.InsideSalesperson__r.Name); }
the above code returns the following debug info.
cv.is=005i0000000jo3XAAQ
cv.is.email=null
if I run this SOQL query in developer console
SELECT InsideSalesperson__c,InsideSalesperson__r.email,InsideSalesperson__r.name from Community_Visit__c where account__c = '001e000000C1FwE'it returns
InsideSalesperson__c = 005i0000000jo3XAAQ
InsideSalesperson__r.Email = mary.k@emaiaddress.com
InsideSalesperson__r.Name = Mary K
so why is it returning null in apex ?
FYI this code is called from a trigger
thanks, Eric J
In trigger you can not get the "InsideSalesperson__r.email" value from Trigger,new or Trigger.old List. Because trigger only contains its record value not parent info. So you have to first collect the "InsideSalesperson__c" id in set and then you have to query on User object whose id in set. And then get each related data by Map.
If you provide you trigger code then I can help you more.
IF it helps you than please mark it as a solution and ENJOY APEX
All Answers
In trigger you can not get the "InsideSalesperson__r.email" value from Trigger,new or Trigger.old List. Because trigger only contains its record value not parent info. So you have to first collect the "InsideSalesperson__c" id in set and then you have to query on User object whose id in set. And then get each related data by Map.
If you provide you trigger code then I can help you more.
IF it helps you than please mark it as a solution and ENJOY APEX
Thanks,
Thanks to accept my suggestion.
Enjoy Apex.