You need to sign in to do that
Don't have an account?
Chad Coffey
Create apex trigger on Opportunity to update Account based on Contact selected
I am not looking for a Process Builder as I want to this update automatically and not wait until the Record is saved for this to be updated. Here is what I ahve started with. Any help would be greatly appreciated!
trigger <addaccount> on Opportunity (after insert,after update) {
for (Opportunity op : [select Account.Name from Contact.id])
trigger <addaccount> on Opportunity (after insert,after update) {
for (Opportunity op : [select Account.Name from Contact.id])
Try this!
All Answers
Try this!
So unfortunately this is not working. Although I am not getting any errors, the automatic insert of Account on the Opportuntiy based on the Contact listed, is not populating. I changed the Contact_Lookup_Field to Hiring_Manager_C (which is the custom lookup field for Contact on the opportunity). Any additonal help would be greatly appreciated!
I'm running same code at my end and its working fine for newly inserted opportunities. So make sure you these things:-
- Trigger will run on insert of Opportunity
- Make sure your Contact record have Account Name.
Test it and let me know again.
Thanks for the help on this!