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
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
http://help.salesforce.com/HTViewHelpDoc?id=fields_about_roll_up_summary_fields.htm&language=en_US
Virendra ChouhanVirendra Chouhan
Hi 
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.

Regards 
Viru
K.G.K.G.
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!
https://success.salesforce.com/ideaview?id=08730000000BrdvAAC
https://success.salesforce.com/ideaView?id=08730000000DpQGAA0
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.