You need to sign in to do that
Don't have an account?
Automatically Add Contact Role Record to Opportunity
As you know, the Contact Role object can not have fields added to it. In order to get around this I have created a custom object called Contact Roles and gave it a child relationship to the opportunity object. The custom object has the same two fields that are on the Contact Role object, ContactID and Role, but also has additional fields on it.
What I would like to have happen is every time a Contact name and Role has been entered into the custom object and saved, a new Contact Role is automatically created on the opportunity with the same Contact name and Role. Does anyone know of a solution for this?
Regards,
Andrew
Hi,
You need to write a trigger on your new custom object for after insert, which inturn create a new record in the standard OpportunityContactRole object.
trigger abc on Cotnact Role
{
for(Contact Role c : Trigger.New)
{
OpportunityContactRole o = new OpportunityContactRole;
o.ContactId = set the contact id here;
o.OpportunityId = set the Opportunity id here;
insert o;
}
}
I got it. Thank you for your help!
Andrew