Is there any way to create campaign members from a new OpportunityContactRole created within an Opportunity? The absence of a trigger for new OCRs makes it seem difficult, if not impossible to complete this task. Simply using the trigger for a new Contact doesn't work since it is not yet associated with an Opportunity until it has already been created. Can anyone shed some light on this for me?

  • Try by replacing the standard OCRs by a customObject. There you'll have a trigger. – Martin Borthiry Dec 28 '13 at 17:00
  • 1
    When do you need the campaign members created? Do they have to be created when the OCRs are added or can they be created once the opportunity hits a certain stage? If the latter, then you could do it with an Opportunity trigger. – Tim Smith Dec 28 '13 at 20:42
  • The Campaign Contacts need to be added as soon as they are added. I managed to find a way around it by creating a small VisualForce object and placing it on Opportunity pages. Any time the opportunity page is hit, this fires a method that adds any contacts within the opportunity to the parent campaign members. – Lee Harrison Dec 30 '13 at 13:12

If you don't need the CampaignMember records created immediately, create a scheduled batch job that queries the OCR records and creates or upserts their CampaignMember records. I'd suggest against using custom objects as mentioned above as you will lose out of the box functionality the CampaignMembers may provide.


Winter 20 enables triggers on OpportunityContactRole (finally) so asynchronous approaches are no longer needed

The trigger would have access to OpportunityId (and ContactId) and hence you can then associate CampaignMembers to the Opportunity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.