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
Brian Hopkins 25Brian Hopkins 25 

Why can we not create triggers on OpportunityContactRole?

There was once an Idea to fix this... https://success.salesforce.com/ideaView?id=08730000000Bqr4AAC

It was eventually marked as Delivered, even though it was not.  However, the shitty experience I've had with Ideas is beside the point.

I need to know why I can't build a trigger on OpportunityContactRole.  There's just... no explanation, anywhere.  I tried opening a Case, and those people did not even understand what I was talking about...  Maybe it's just me but I have been having a brutal time with any sort of service coming directly from Salesforce.

I accept that Salesforce isn't going to lift a finger to solve the issue of not being able to create triggers.  Why would they, they already have my money.  I just want a straight answer - why?  Is that too much to ask?
Shivdeep KumarShivdeep Kumar
Hi Brian,

The idea link you have mentioned is for campaignMember and for OpportunityContactRole please click on below link to vote
https://success.salesforce.com/ideaview?id=08730000000BrdvAAC  (https://success.salesforce.com/ideaview?id=08730000000BrdvAAC)

 
But If you want to do CRUD on OCR, then there is three workarounds as I read.
 
  1. Run a scheduled batch apex job that sweeps the Opportunities (or Contacts) and looks at their OCR and compares them to previously saved OCRs.
  2. Create an 'on view' trigger for your standard Oppo page layout that compares the current OCR to some prior value of the OCR. See http://www.soliantconsulting.com/blog/2012/08/view-triggers-salesforce-trigger-opportunity-contact-roles .
  3. Adding logic to opportunity trigger so every time an opportunity is edited, it will query on OpportunityContactRole to roll up (personally I do not recommend this).
Please let me know if this help !

Thanks
Shivdeep
Brian Hopkins 25Brian Hopkins 25
Hi Shivdeep, thanks for your response.  Indeed, those are the three best options that I have found online.  I worked on this with my teammates and we came to the conclusion that the Scheduled Batch job is the best way to go.  It is the least pervasive solution, and since the results will only be used in occasional reporting, it does not need to be a real-time update.

But my question is really -- is there a reason why they didn't allow triggers on the OCR object?  Why not treat it like every other object?