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
nikkeynikkey 

Rollup Summary Value to be changed based on condition

Can any one help me on this? I have a Visualforce page created on Opportunity object which is PDF format. I have few RollUp summary fields created on opportunity object. There is a Wrapper class written on Opportunity Product. Now I would like to call this RollUp summary fields in wrapper class based on the Condition. How to wrap the RollUp summary field in a class? Any help very much appreciated.

"Subtotal__c" and "Non_Pick_Total__c" are Roll up summary fields on Opportunity Object.Their give the "Sum" of Opportunity Product aggregates on Extension Field. Extension(Extension=qty*1) is a Formula field data type as Currency on Opportunity Product.
 
The issue is the "Extension" field value is getting calculated based on the formula field but it should get calculated as per the changes made in visual force page and display (Extension =Qty*0.01) on the subtotal.
Condition :

If the product line for the product selected in opportunity items is ‘DIE’ make following changes .

1) unit price should change to $.01.

2)Unit price just change on the PDF display only and with extended amount which will be quantity times .01.

3)Subtotal__c=Non_Pick_Total__c

Code :
if(OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') 
                     {
                      tempObj.unitprice=0.01;
                      tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
                      tempObj.productname=OPplineitem[i].Bin_Item_Code__c;
                    //tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c*0.01;
                     // tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c*tempObj.unitprice;

                    //tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c*tempObj.unitprice;

                     }
                 else
                     {
                     tempObj.unitprice=1;
                     //tempObj.unitprice=OPplineitem[i].ListPrice;
                     tempobj.extension=OPplineitem[i].Extension__c ;
                    }


 
ShashankShashank (Salesforce Developers) 
You can read about wrapper class here: https://developer.salesforce.com/page/Wrapper_Class