You need to sign in to do that
Don't have an account?
SFDC@Chennai
How to add a multiple values in list of same fields/variable
Hi
I need to create a list in that i have add 6 values, finally that list should be inserted in db,
My code is as below,
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(frr.Forecast_Amount__c != 0){
frr.Forecast_Amount__c = this.amount1;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount2;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount3;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount4;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount5;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount6;
frList.add(frr);
frr= null;
}
insert frList;
In this case i can insert only frr.Forecast_Amount__c = this.amount6;value(list contain final value), but i need to get all the 6 types of amonut in Forecast_Amount__c filed/ List(frList) can any one help for this!
I need to create a list in that i have add 6 values, finally that list should be inserted in db,
My code is as below,
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(frr.Forecast_Amount__c != 0){
frr.Forecast_Amount__c = this.amount1;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount2;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount3;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount4;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount5;
frList.add(frr);
frr= null;
frr.Forecast_Amount__c = this.amount6;
frList.add(frr);
frr= null;
}
insert frList;
In this case i can insert only frr.Forecast_Amount__c = this.amount6;value(list contain final value), but i need to get all the 6 types of amonut in Forecast_Amount__c filed/ List(frList) can any one help for this!
All Answers
you can refer below code:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
Should we initialize frr(Object Reference) all the time?