From some research, I've seen many previous examples having the update inside a for loop which would reach over 150 DML statements if there were. I'm wondering why I still get the issue that there are too many DML statements. I update it outside the for loop so that should only be 1 DML statement. Is there any other way to make the for loop?
List<Opportunity> opportunities = [Select id, amount, btcAmount__c from Opportunity];
for(Opportunity opp: opportunities){
if(opp.Amount != null) {
opp.btcAmount__c = 200;
}
else {
opp.btcAmount__c = null;
}
}
try {
update(opportunities);
}
catch (exception ex){
system.debug(ex.getMessage());
}
(cacheable=true)
parameter?