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
jcaldjcald 

DML currently not allowed

Can someone help. Im getting this error and know not how to resolve.


System.LimitException: DML currently not allowed
Class.WorksheetLender.getRateX: line 33, column 1


public Price_Range__c getRateX() {
Lender__c a = new Lender__c (Name = 'KEY');
insert a;
String Key ;
Decimal amount=[SELECT Finance_Amount__c FROM Worksheet__c LIMIT 1].Finance_Amount__c;
if(amount >150000 && amount <250000){
Key='a67K00000004Emt';
}
if(amount >99999 && amount <149999){
Key='a67K00000004Emy'; 
}
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =: a.id  LIMIT 1];
}


I know that this isn't best practice to hardcode id but this is only practice knowledge. And then work my way up to bulk and simplify. Thanks for your help
Phillip SouthernPhillip Southern
Where are you calling this from?  VF page, trigger, batch, etc...
jcaldjcald
Above is from my Controller.

and this is from my VF.

<td width="150px">
<apex:outputfield id="lender4" value="{!lender4.Name}"/>(<apex:outputtext value="{!RateX.Range_Rate_Month24__c}"/>)
</td>