function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nate BakerNate Baker 

Update Contact record when added as Opportunity contact role

I'm trying to check a checkbox on the Contact record when it's added as an Opportunity contact role. I've been able to do this for other objects where the contact is a lookup field, but not for contact roles.

Best case: check a checkbox on the contact record when it's added as an opportunity contact role
Worst case: check a checkbox on the opportunity record if contact roles exist on that opportunity.

Thanks!
AndrewTaylorAndrewTaylor
The OpportunityContactRole does not support triggers; if you can live without it being real-time, you could write a schedulable job to query the new OpportunityContactRoles created over a 24 hour period, and update the related Contact records.
Nate BakerNate Baker
I don't mind the 24-hour wait. What type of job should I schedule?
AndrewTaylorAndrewTaylor
You can create an Apex Class implementing Schedulable: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

Depending on the volume of records you expect, you may want to implement Batchable as well: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm