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
kstites2001kstites2001 

Count of Contacts on an Account in a field

I am trying to write a formula field to count the number of Contacts under an Account so that it could be used for reporting.  Can someone point me in the right direction for how to accomplish this?

ericmonteericmonte

You cant do this with a Formula nor a Roll Up Summary because of the relationship of Accounts and Contacts. For you to figure out the count of Contacts under the Account, you can either pull a report and group it by Accounts or create a trigger that will count the number of contact for the Account.

Satish_SFDCSatish_SFDC
If you want the count as a field on the Accounts page, the best option would be a trigger.
But make sure you also write code to deal with contact deletions and undeletions apart from inserts.
You will have to update the field in accounts as necessary.

Regards,
Satish Kumar
rbohnrbohn

To count contact records on your Accounts there is a great AppExchange app called Rollup Helper.

 

Check it out.