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
Thomas Graves 1Thomas Graves 1 

Iterate over Product2 in QuoteLineItem from a Quote Field

Hi Everyone,

I have a custom Quote Field, lets call it 'Count'. I want the value of Count to come from looking at all the names of the products in the Quote Line Items and generating a value. I've figured a few things out on my own but my resources are running dry. Below is everything I've figured out

QuoteLineItem - the name of the object containing each product
Product2 - the product name that is displayed in QuoteLineItem
Count - this should be a custom formula field. the formula should look something like what I have below ->

count = 0;
For (all QuoteLineItem:x in Quote object){
    If (x.Product2 = 'ABC')
        count = count + 5;
    If (x.Product2 = 'DEF')
        count = count + 10;
     If (x.Product2 = 'GHI')
        count = count + 5;
}

Am I thinking about this right? Can someone help me pull this thing together.

Thanks!
T




 
Best Answer chosen by Thomas Graves 1
Thomas Graves 1Thomas Graves 1
Hi Guys,

I figured this out. Here is what I had to do.

I made a formula QLI field (x1) to determine the individual count associated with each QLI.
Then I made a number QLI field (x2) that was populated with the value of x1 by a workflow field update rule.
Then I made a Roll Up Summary Quote field (y1) to calculate the total sum of x2 across all QLIs.

You have to use this method because you aren't allowed to have a Roll Up Summary field that is based on a formula field

Hopefully this helps someone out there.

--Thomas

 


 

All Answers

Balaji BondarBalaji Bondar
Hi Thomas,
1. Create count formula field on the QuoteLineItem with above logic and get the count based on Product per QuoteLineItem .
2  Create a Rollup summary field on the Quote with Sum(Count at QuoteLineItem level)

 Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Thomas Graves 1Thomas Graves 1
Hi Balaji,

Thanks for the response. The Rollup summary will not meet my needs. I need to increment the value of count based on the title of the product.
So if the Product was called "ABC", count will increment by 5 - if Product was called "DEF", count will increment by 10 - etc.

I also have a knowledge gap related to writing a formula that iterates through all QuoteLineItems and grabs the Product2 field (Product2 is the name, correct?).

Thanks,
T
C. Praveen kumarC. Praveen kumar
how about two rollup summary field to count Product ABC and Product DEF. And a formula field to calculate the sum of both products i.e formula field = (rollup1 count value * 5 + rollup2 count value * 10)
Thomas Graves 1Thomas Graves 1
Hi Guys,

I figured this out. Here is what I had to do.

I made a formula QLI field (x1) to determine the individual count associated with each QLI.
Then I made a number QLI field (x2) that was populated with the value of x1 by a workflow field update rule.
Then I made a Roll Up Summary Quote field (y1) to calculate the total sum of x2 across all QLIs.

You have to use this method because you aren't allowed to have a Roll Up Summary field that is based on a formula field

Hopefully this helps someone out there.

--Thomas

 


 
This was selected as the best answer