Exception:
If you use below code it will throw an error System.LimitException: Too many DML statements: 1 ,it is because you have an dml statement in your aura-method which is enabled for cache.
Workaround:
Please remove (cacheable=true) from your method declared above,then this will work without any error
If you use below code it will throw an error System.LimitException: Too many DML statements: 1 ,it is because you have an dml statement in your aura-method which is enabled for cache.
public with sharing class GetAllAccountsCntrl { @AuraEnabled(cacheable=true) public static List<Account> processAllAccounts() { List<Account> lstAcc = new List<Account>(); for(Account acc:[SELECT Id, Name,AccountSource,Website, Createddate FROM Account Limit 10]) { acc.Name = 'LWC Testing...'; lstAcc.add(acc); } Database.update(lstAcc,false); return lstAcc; } }
Please remove (cacheable=true) from your method declared above,then this will work without any error
public with sharing class GetAllAccountsCntrl { @AuraEnabled public static List<Account> processAllAccounts() { List<Account> lstAcc = new List<Account>(); for(Account acc:[SELECT Id, Name,AccountSource,Website, Createddate FROM Account Limit 10]) { acc.Name = 'LWC Testing...'; lstAcc.add(acc); } Database.update(lstAcc,false); return lstAcc; } }
Please comment or write us if you have any queries/requirements.
Please like,follow,bookmark,subscribe this site to receive daily updates.
Please like,follow,bookmark,subscribe this site to receive daily updates.


refreshApex is not working if cacheable=true removed.
ReplyDeletethanks
ReplyDeleteI have removed cacheable = true and i m not even using wire but still getting too many dml statements : 1
ReplyDeleteHow do i fix this
use @AuraEnabled(cacheable=false) and try. it will work.
DeleteI had tried with (cacheable=false). Still getting the same issue.
Delete55718C6B0E
ReplyDeletekiralık hacker
hacker arıyorum
kiralık hacker
hacker arıyorum
belek
2835FC14
ReplyDeleteGümüşhane Esçort
Elazığ Esçort
Kırıkkale Esçort
Urfa Esçort
Kayseri Esçort
Bingöl Esçort
Iğdır Esçort
Amasya Esçort
Konya Esçort
08221DE3
ReplyDeleteChat aleatorio
Willekeurige chat
Obrolan Acak
Random Chat
Obrolan Acak
Chat aleatoriu
Slumpmässig chatt
Zufälliger Chat
צ'אט אקראי