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 

Apex Code Logic written to change the value in visualforce page doesnot work

Can any one help me on this? I have a Visualforce page created on Opportunity object which is in PDF format. I have a few RollUp summary fields created on opportunity object. There is a Wrapper class written on Opportunity Product. Now I would like to call these RollUp summary fields in the wrapper class based on a Condition. How do I 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. They 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 I'm having is that the "Extension" field value is getting calculated based on the formula field but it should get calculated as per the changes made in the VisualForce page and display (Extension = Qty*0.01) on the subtotal.
Code :
for (integer i=0; i < OPplineitem.size(); i++) {
    tempObj = new wrapperClass();
    tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
    tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
    tempObj.quantity=OPplineitem[i].Quantity;
    tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
    // tempObj.Subtotal =OPplineitem[i].Opportunity.Subtotal__c;
    //   tempObj.NonPickTotal=OPplineitem[i].Opportunity.Non_Pick_Total__c;
    //Add a conditional statement here
    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;

        if (i==0) {
            tempObj2.Subtotal=tempobj.extension;
            system.debug('@@@@@@@@'+tempObj2.Subtotal);
        } else {
            tempObj2.Subtotal=tempObj2.Subtotal+tempObj.extension;
        }
    } else {
        tempObj.unitprice=1;
        //tempObj.unitprice=OPplineitem[i].ListPrice;
        tempobj.extension=OPplineitem[i].Extension__c ;
    }
}
When i check in the Debug logs the value gets calculated but it does not get changed in the visual force page.Any help very much appreciated.