You need to sign in to do that
Don't have an account?

trigger to add contact as contact role when creating opp on contact
Hi,
When an opportunity is created from a contact, I want this contact to them become the contact role on that opportunity.
I know this is standard functionality in salesforce but I have to created a custom button to create a new opportunity as it updates a few fields so lost this functionality......unless there is an easier way to keep the origional New button and then default some fields before the report is created?
Thanks
When an opportunity is created from a contact, I want this contact to them become the contact role on that opportunity.
I know this is standard functionality in salesforce but I have to created a custom button to create a new opportunity as it updates a few fields so lost this functionality......unless there is an easier way to keep the origional New button and then default some fields before the report is created?
Thanks
All Answers
Sample Code
Opp.Name = 'Opportunity Name'';
Opp.StageName = 'Interest';
Opp.AccountId = Contact.AccountId;
Opp.CloseDate = System.Today().addDays(30);
Insert Opp;
OpportunityContactRole CntRole = New OpportunityContactRole();
CntRole.ContactId = Contact.Id;
CntRole.OpportunityId = Opp.Id;
Insert CntRole;
I created the lookup field and passed it in my button, then created a flow and process to create the contact role