Search code examples
salesforceapex-code

how do we sync OpportunityContactRole with another custom object


I have opportunity which has a related list contact roles and there is another custom object called Project which has another related list called Keycontacts.

I need to sync opps with events which is happening fine. But I also need to sync contact roles (OpportunityContactRole) with Keycontacts. I just found that Triggers are not allowed on OpportunityContactRole.

Opp and OpportunityContactRole are related with oppid Project and Keycontacts are related by projectid

Project and Opp are related with oppid. Project have lookup for opp ids.

How could we sync these 2 objects without using trigger on OpportunityContactRole .

Any pointers?


Solution

  • When triggers aren't an option a nightly process to sync the tables is an option.

    Create a batch class that runs over the opportunity contact role and syncs it to the key contacts table. Then implement the schedulable interface so that you can schedule it to run at a predefined intervals.