I need to mark a field on account (can be roll-up), based on if an item exists or not in any of it's closed-won opportunities.

  • I want to have that for all historical data as well (I can use a WFR, but that will only update new/updated opptys)

    • Rollup summary can not work, neither from account, nor from oppty (can't iterate the product line items)
    • Simple formula - again, can't iterate, nor does it see lineitems.

    ** I can't filter the roll up by name.

  • I looked at Andrew's https://github.com/afawcett/declarative-lookup-rollup-summaries - This does not give me access from account to line-item

The first tackle will be to mark the Oppty based on the product (from there I can do the Account-Oppty rollup.

But how do I do that? (not using WFR)

---- Available fields for filter on the roll up enter image description here

  • What do you mean with "can't iterate the product line items". You could just create a roll up summary on Opportunity of Opportunity Products, which is what you need, right? Oct 7, 2015 at 13:43
  • yes, only that I can't filter by the product name, "aggregatable" fields.
    – Saariko
    Oct 7, 2015 at 15:07

3 Answers 3


This seems too simple (maybe I am missing the OPs requirment) but here it goes:

  1. Create a rollup field on Opportunity called Count_Of_Product__c
  2. This rolls up the count of a specific product (defined in rollup) on the opportunity
  3. Add a Roll up on Account say Count_Of_Product__c that rolls up the Opportunity.Count_Of_Product__c

Done. A Rollup of a rollup

  • I can't filter by name of product.
    – Saariko
    Oct 7, 2015 at 15:09
  • What about product ID? You could also add a field on OLI to populate a Text field with the Product Name (WFR or PB). Then you could use that to filter....
    – Eric
    Oct 7, 2015 at 15:10
  • not available. see in Q new image
    – Saariko
    Oct 7, 2015 at 15:12
  • 1
    Then the second part of my comment should work. But it will require a WFR (even a before update trigger) to populate a text field. That field should then be available for a rollup filter on opp
    – Eric
    Oct 7, 2015 at 15:14

I'd recommend you consider running a schedulable class to do the work for you. Presumably you could schedule the class to either run from a trigger or run daily (your choice). See Dan Appleman's DF14 Video Design Patterns for Asynchronous Apex along with the new release of his book Advanced Apex Programming Ver 3. The sample code from the webinar is available at http://advancedapex.com/dreamforce13/. This would allow you to capture your historical data while also maintaining it as new opportunities are closed using the same design pattern without consuming a lot of API calls.

  • Thanks, I always try to avoid code. Especially with Builder and visual flow now available.
    – Saariko
    Oct 7, 2015 at 15:09

Solved with the Declarative Lookup Rollup Summaries by Andrew.

Since the 'Name' field is not visible on the productlineitem (yea, weird) I used the 'ProductCode'

Gave the products a unique code, and the declarative rule is based on it.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .