Please help I want to get the Account.Name from the Account object from the Contact (after iupdate) Trigger. Below my trigger.but currently its giving only null for c.Account.name..
trigger Contactcallout on Contact (after update) {
Map<Id, String> m = new Map<Id, String>();
for (contact c : Trigger.new) {
if(c.RecordTypeId == '012D0000000BaFA'){
contact old = Trigger.oldMap.get(c.Id);
if (c.Email != old.Email||c.FirstName!=old.FirstName||c.LastName!=old.LastName||c.phone!=old.ph one||c.Title__c!=old.Title__c||c.Account.name!=old.Account.name) {
WebServiceCallout.sendNotification(c.Id,c.Email,c.FirstName,c.LastName,c.phone,c
.Title__c,c.Account.name);
}
}
}
}
Parent fields values are not accessible from Trigger.new, you need to retrieve them from SOQL. Check the trigger below:
Try above code, and one more thing you should never hardcode a record id in apex.
(Edit: For some reason it doesn't allow me to post the trigger as Code, So added it as a HTML to the comment.)