You need to sign in to do that
Don't have an account?
Tobias Hagge
Trigger from Opportunity to Contact
I would like to do a trigger on Opportunities to rollup values into the Contact object. We don't use ContactRoles. There is a lookup fields to the relevant Contact on the Account, but the following gives a null ID.
Map<String, Opportunity> opportunityMap = new Map<String, Opportunity>(); for(Opportunity opportunity: opportunities) { String id = opportunity.Account.Contact__c; System.debug ('*****' + id); if(id != null) opportunityMap.put(opportunity.Account.Contact__c, opportunity);Any ideas?
Relationship fields are not available inside trigger.new so you need to query them in sepeate SOQL.
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer.