I have created 4 custom fields on account, and I want those fields to store the number of opportunities according to their status(e.g. Active, Inactive, Open, Lost). Once the admin creates an Open Opportunity on an Account, the number of Open Opportunities [which is a custom field on Account] should increase. I've tried using Process Builder, Apex classes/triggers and Workflow rules all in futility.


You can use simple roll-up summary fields. Go to the Customize Accounts Fields area in Setup, and create four new roll-up summary fields, one for each status. If you'd like to do this with Apex Code, you should search other questions on this forum that include answers from several sources on how to build a custom roll-up relationship trigger, or consider using the Declarative Roll-Up Summary tool that's already been built.

| improve this answer | |
  • I thought Roll-up summary field values cannot be changed. Apparently, that's false. @sfdcfox – Oladipo Mar 12 '16 at 18:33
  • @DIPXOID They can't be changed by users (cannot be edited), but will always show correct values, which is presumably the purpose of creating those fields. – sfdcfox Mar 12 '16 at 18:34
  • Alright. I will check it out and rate the answer as appropriate. – Oladipo Mar 12 '16 at 18:39
  • The issue with this I've been struggling with is that the easiest way is to create new roll-up summary fields. But I can't use TODAY (I mean today's date) as a condition in it; and I need it. The other options to use are not as straightforward. – Oladipo Mar 16 '16 at 9:39

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.