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.
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.
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.