You need to sign in to do that
Don't have an account?
kladizkov
Accessing 'Name' of a lookup relationship
Hi,
In my contact, I have a custom lookup field called 'Favorite Place'. I have a trigger that fires before record update. And, in the Apex class method I'm trying to mail the 'Favorite Place' of that contact. I used the below code
mail.setHTMLBody('Place: ' + c.Favorite_Place__r.Name);
But, it says 'Place:null' in the email. But, in contact the field 'Favorite Place' has been correctly populated as 'Hawaii'. Any idea, what i'm doing wrong here.? Please help.
aalbert
The relationship fields are not populated by default on a trigger. You need to query explicitly for related field values.