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
sdondetisdondeti 

Update Opportunity with Product custom fields

Hi,

We are capturing a few custom fields at product level and wanted to use them in some calculation. The result of the calculation needs appear on Opportunity custom fields.

Let us say, the product has field1 and field2 custom fields..I wanted to multiply these fields first and summarize this value for all products and update on opportunity(kind of rollup)

Example formula: SUM of all products(field1 * field2).

Having said that, I tried with workflow field update..I was able to get the custom field in workflow field update on OpportunityLineitem but I don't know how to to aggregate this for all products.

I was thinking trigger is the only option for this and here is the approach.
  1.     Create a trigger on OpportunityLineitem which gets fired anytime a product added to Opportunity
  2.     In the trigger do calculation based on the product custom fields and aggregate the value for all line items.
  3.     Update opportunity.

Before moving forward, I wanted to make sure I am in the right direction OR it could be achieved with out a trigger using workflow field update or any other means.

Appreciate your feedback.

Thanks.
Christopher ShadeChristopher Shade
Hi sdondeti,

I think I would create a formula field (field3) on each product that multiplies field1 * field2.  Then I'd just use the roll-up summary field on the opportunity to sum all that field3 fields on the all the products.

Chris

If this helped click Like.