Is it possible - I have a use case - When a user creates a new opportunity record, they will not be able to save it until they have added one Contact Role. Any Suggestions??


This is a bit of a pain as you can't use a roll up summary field or write a trigger on the OpportunityContactRole object. This is a free, unmanaged, Appexchange product that does this:


Note the most helpful negative review:


The issue is the trigger fires on Opportunity updates so the user will have to cancel out and add a OCR (potentially having to create a Contact first etc).

I have used a modified version of this in combination with a validation rule so that a OCR must be present at a certain stage, but we have actually adopted a different approach. We replaced the New Opportunity screen with a custom VisualForce page that included a section dedicated to making it easy to add an existing Contact as an OCR or creating a brand new Contact all from the same screen.

We decided this was more user friendly as well making all the Opportunities populated with an OCR from the start - so better data quality earlier.

  • Hey Girbot!, Just wanted to let you know that the free app logic doesn't actually execute until you actually update something on the related Opportunity. Seems that its not making Contact Roles required on new Opportunities insertion. – Sunil Sharma Nov 18 '14 at 10:15
  • That's exactly what I wrote in relation to the most helpful negative comment - it is unfortunately a system limitation and this is the best you can do as we do not have access to write triggers on the object OpportunityContactRole – Girbot Nov 18 '14 at 10:18

You can not assign contact role to opportunity when opportunity does not exist. So you first have to create opportunity then you can assign contact role to it. While your trigger may work on update event. In addition to this If you prefer to use custom page to create opportunity with related list then you can achieve this by providing feature to create contact role related list.

Thanks, Vikas


One Solution

Create a lookup field on Opportunity to Contact and expose it on Opportunity Page Layout. Call it 'Primary Contact' and make it required. Now you can write an afterinsert trigger on Opportunity and fetch the value from this field 'Primary Contact' and insert Contact Role in Apex.


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.