• Kai Cheung
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
Hi Newbie here,

In my Opportunities Tab, I have a lookup field called "relationship manager".  It looks up Contact for the relationship manager.

My goal is to write a trigger that when create or update an Opportunity and input the Relationship manager fields, it automatically create a Contact Role for the same person.

This is what i have so far, I dont know how to extract Opp ID and Contact ID as I think I will need it.  Please help.

Trigger CreateContactRole on Opportunity (after insert, after update)
{
For (Opportunity N:Trigger.now)

Opportunitycontactrole A = New Opportunitycontactrole ();
A.oppid = n.oppid;
a.RMID = n.rmid;
a.Role = ‘Relationship Manager’;
a.Isprimary = ‘True’;
}
Hi Newbie here,

In my Opportunities Tab, I have a lookup field called "relationship manager".  It looks up Contact for the relationship manager.

My goal is to write a trigger that when create or update an Opportunity and input the Relationship manager fields, it automatically create a Contact Role for the same person.

This is what i have so far, I dont know how to extract Opp ID and Contact ID as I think I will need it.  Please help.

Trigger CreateContactRole on Opportunity (after insert, after update)
{
For (Opportunity N:Trigger.now)

Opportunitycontactrole A = New Opportunitycontactrole ();
A.oppid = n.oppid;
a.RMID = n.rmid;
a.Role = ‘Relationship Manager’;
a.Isprimary = ‘True’;
}