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
SFDC@ChennaiSFDC@Chennai 

I want the values to be updated, but its getting inserted. when ever i click save button.

Hi

i have 4 INputtext

amount1:
amount2:
month1:
month2:

public PageReference save() {
  List < Forecast_Revenue_Report__c > frList = new List < Forecast_Revenue_Report__c > ();
  Forecast_Revenue_Report__c frr = new Forecast_Revenue_Report__c();
  frr.opp_id__c = opp.Id;
       if (this.amount1 != null) {
   frr.Forecast_Month__c = this.month1;
   frr.Forecast_Amount__c = this.amount1;
   frList.add(frr);
  }

  Forecast_Revenue_Report__c frr2 = new Forecast_Revenue_Report__c();
  frr2.opp_id__c = opp.Id;
  // frr= null;
  if (this.amount2 != null) {
   System.debug('this is for total' + frList);
   frr2.Forecast_Month__c = this.month2;
   frr2.Forecast_Amount__c = this.amount2;
   frList.add(frr2);
  }

                upsert frList;
  PageReference oppPage = new PageReference('/' + ApexPages.currentPage().getParameters().get('id'));
 
       
  System.debug('this is for testing i above save' + oppId);
     if(oppId != null ){
            System.debug('this is for testing i Update' + oppId);
   update frList;
  } else  {
            insert frList;
   System.debug('this is for testing i saved' + oppId);
          
  }
       
  return oppPage;

when i  click save button the values are getting added, i want the values to be updated

Thanks in advance
Grazitti TeamGrazitti Team
Hi,

why are you upserting the records?

--
Regards,
Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com