-1

I have a monthly amount roll-up sum field on my opportunity. The child objects are the opportunity products. Is there a way to exclude one specific product from this lookup?

BR Alex

enter image description here

enter image description here

Edit: So the pic shows what actually is available. But I would like to add some kind of criteria so I can filter one specific product from the sum rollup field if it is selected within a opportunity. Like a product code. Right now I have no clue how I can exclude a specific product in the roll up field.

9
  • What's the problem with what you have shown here? Can you please edit to show what you have actually tried and where it is failing?
    – Phil W
    Mar 22, 2023 at 13:36
  • @PhilW I tried to clarify it: But I would like to add some kind of criteria so I can filter one specific product from the sum rollup field if it is selected within a opportunity. Like a product code. Right now I have no clue how I can exclude a specific product in the roll up field
    – Alex M.
    Mar 22, 2023 at 14:09
  • roll up of cross-object fields is not possible - see this q&a for workaround (though you would use Flow now, not WFR/PB)
    – cropredy
    Mar 22, 2023 at 16:01
  • 1
    I assume the "opportunity products" are master detail children of "opportunity" - otherwise you can't create the rollup - and then that the products themselves have a value that you are summing in the rollup. If that's the case, I don't understand why you can't have a criteria that selects or excludes "opportunity products" from the rollup calculation using criteria against the product's type. I'm not understanding the issue because you have not provided detail of the object model in question, I guess.
    – Phil W
    Mar 22, 2023 at 16:33
  • @PhilW Yes you are right in summarize the case. The problem is that I have no option using the product type or product code inside the criteria (as shown above - that are the only fields I have for the criteria) so I can´t exclude the product. The question was how can I achieve it anyways? :)
    – Alex M.
    Mar 23, 2023 at 21:10

1 Answer 1

1

Because OpportunityLineItem.ProductCode is implicitly a cross-object formula field against Product2, it will not appear as a choice in the available filter fields for RSF

Options

OPTION 1 - Each time the OpportunityLineItem is created, copy the value of OpportunityLineItem.PricebookEntry.Product.ProductCode to a custom Text field on Opportunity Line Item. This custom text field will be available for filtering

You can use a Flow or Apex trigger to do this. This answer can be used as a guide (albeit for WFR but Flow or triggers can be used too)

Minor downside - if the related Product's ProductCode is updated, the copy in the OpportunityLineItem won't be updated

OPTION 2 - Use Declarative Lookup Rollup Summary github repo (a super popular tool). It is not bound by the related object restriction of RSF and also works across lookup relationships as well as master-detail. Under the covers, DLRS uses triggers that are highly optimized.

1
  • Thanks. Took me a while but I think I get it :) Will try it in a sandbox.
    – Alex M.
    Mar 27, 2023 at 7:19

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