+ Start a Discussion
5th Wheel Steve5th Wheel Steve 

How to create a field to count opportunities per contact?

I am looking to find which contacts are our most prolific.
Is there a simple way without triggers?
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
if they are in relationship  go for rollup summary field
Virendra ChouhanVirendra Chouhan
I think Trigger is the only way because rollup summary is available in Master-Detail relationship and there is no way to create Master-Detail relationship b/w Contact and Opportunity.

I've become convinced that this can't be done, even with triggers.  For example, if doing an "after insert" trigger on Opportunity, it'd fire before you got around to inserting the OpportunityContactRecord you wanted to count.

I'm looking toward my first "Batch Apex" and hoping updating the field I want to populate on Contact once a day is enough.

(Of course now I'm running into SOQL limitations, like not being able to compare the OCR count against a numeric field on Contact in a HAVING, but that's another story.)

In the meantime, please upvote these 2 ideas to allow us to write code against OpportunityContactRole so we can actually get counts of Opportunities hanging off of Contacts working!
Kevin Charette 8Kevin Charette 8
I had to do this recently. Rollup Helper was there to do it. You get three roll ups for free. Easy took 5 minutes to set up.