21
votes
Accepted
Storable Action - System.LimitException: Too many DML statements: 1
Simply remove the (cacheable=true) parameter from your @AuraEnabled annotation. Caching a delete operation does not make any sense, and is not allowed.
If you read Lightning Components Best Practices:...
10
votes
Accepted
Is DML not allowed in a Visualforce getter?
Here ya go. According to Considerations for Creating Custom Controllers and Controller Extensions
You can't use data manipulation language (DML) operations in a
“getxxx” method in a controller....
9
votes
How do I replicate an apex heap size exception in a test class?
Is it possible to catch a heap size exception through code?
No.
If so, what's the easiest way to re-create this exception in a test class, if it's even possible?
You can easily create the ...
9
votes
System.LimitException: Too many SOQL queries: 101
Rishi Golyan correctly identified the issue, however, Messaging.renderStoredEmailTemplate() works on single ids rather than a list of ids.
So, simply moving that method call to be outside of your ...
9
votes
Accepted
System.LimitException: Too many SOQL queries: 101
Hi You are getting the error because you are using Messaging.renderStoredEmailTemplate() in for loop as this is counted towards the SOQL governor limit as one query. To avoid the exception you have to ...
8
votes
Accepted
Querying of Apex Properties
Yes, they re-run every time. A common pattern to avoid it is called Lazy Loading:
public User current_user
{
get
{
if (current_user == null)
{
current_user = [
...
7
votes
Storable Action - System.LimitException: Too many DML statements: 1
Reason for that is your
cacheable=true
annotation. When you are doing caching you cannot mutate any data. You can only get data. So thats why no DML operation is allowed i.e Total DML operation ...
6
votes
Storable Action - System.LimitException: Too many DML statements: 1
You're performing DML in a context that is not supposed to mutate data - a cacheable @AuraEnabled method:
To improve runtime performance, set @AuraEnabled(cacheable=true) to cache the method ...
6
votes
Avoid too many SOQL calls in APEX Select COUNT()
You are running a SOQL query in a loop, which violates the first principle of bulkification. Simply move the query out of the loop and use GROUP BY:
SELECT COUNT(Activity_Type__c) count, WhatId
FROM ...
6
votes
Accepted
Avoid too many SOQL calls in APEX Select COUNT()
You can use an additional GROUP BY to get all the values at once.
List<Contact> prospects = [SELECT id FROM Contact WHERE OwnerId = '00651000003CWWpAAO'];
Map<Id, AggregateResult> results =...
5
votes
Accepted
MassEmailMessage vs “Too many Email Invocations: 11”
Your entire test method is treated as a single transaction. Since you have the insert inside the for loop, you are executing sendMail 11 times in this single transaction, and thus you get the error.
...
5
votes
Accepted
What is Salesforce Daily api limit per user per 24 hours?
The API Request Limits documentation goes into a bit more detail
Limits and allocations are enforced against the aggregate of all API calls made to the org in a 24-hour period. Limits and allocations ...
5
votes
Accepted
How to get past the URL limit error of maximum 4096 characters?
There are a few options, but basically you need to get the bulk data out of the query string.
Typically you would do this by using a POST request rather than a GET request. Since a PageReference ...
4
votes
Accepted
LWC: Maximum Blob Size From JS To APEX
What would be the maximum size of a blob that I can pass from the JS
side to APEX.
It was documented to be 1 mb from lightning component to Apex in 1 transaction. However I do not find that ...
3
votes
Accepted
Too many query rows : 50001
Query rows are cumulative per transaction. The latter query might be less than 50k, but the total sum is not. If you just need the parentIds, try:
Set<Id> setAttachmentParentId = new Map<Id, ...
3
votes
Batch Apex System.LimitException: Too many query locator rows: 50000001
I suggest that the "quick fix" is running the batch job more frequently e.g. every hour, assuming that the records build up over the day.
But inserting and deleting such large number of objects a day ...
3
votes
Accepted
Why catch code of an try catch exception are not executed when System.LimitException: Too many DML statements: 151
It's buried in the documentation a bit, but on Exception Class and Built-In Exceptions, there is this...
LimitException: A governor limit has been exceeded. This exception can’t be caught.
This ...
2
votes
Why catch code of an try catch exception are not executed when System.LimitException: Too many DML statements: 151
By design, System.LimitException cannot be caught in Apex code. So when that exception is generated, all your code is immediately exited.
This means you must design your code to not generate these ...
2
votes
Accepted
Conflicting triggers
This is a nastier manifestation of this issue, where a batch class (in your case, in Package A) performs record updates that cause triggers to fire (in Package B) that then attempt to enqueue ...
2
votes
Accepted
how to abort upload file when filesize is too large
You need to prevent the default action in order to prevent the submission:
function checkFileSize(event){
if ($("[id$=inputfile]")[0].files.length > 0) {
//validate file attachment is not &...
2
votes
Getting an Error on a scheduled job, but can't find the error
"Apex CPU time limit exceeded" doesn't imply a bug, but that your code/process might not be optimized.
Everything in Production has been tested in Sandbox, and thus far, have not had any ...
2
votes
Accepted
Unsure why: System.LimitException: Too many SOQL queries: 201
You have SOQL in for loop.
Contact[] conList = [SELECT ID, Email, Zenefits_Id__c FROM Contact WHERE Zenefits_Id__c IN : newEmployeeMap.keySet() LIMIT 200];
May be your newEmployees is more. You can ...
2
votes
Accepted
FATAL_ERROR System.ListException: Before Insert or Upsert list must not have two identically equal elements
Non-primitive data types are always passed by reference in Apex. So, you should clone the objects before modifying them for getting the copies.
Implementing as below will remove the reference to ...
2
votes
OrgLimits.getAll() works only with Anonymous apex and gives exception when used in any other context
You cannot return List<System.OrgLimit> directly to LWC as you dont have native javascript methods like getLimit() and getName(). You need to fetch them and return to LWC component:
Apex:
@...
2
votes
What is Salesforce Daily api limit per user per 24 hours?
The API call limit is an org-wide limit. It scales with your user license count, but is not applied on a per-user basis.
Now the question is there a limit to the number of api calls that a user can ...
2
votes
How to get CPU consumed by each Apex
CPU time isn't measured by class that way, so it's impossible to build such an app directly. You'd have to add a method somewhere that every other method would have to call to log the time used. You ...
2
votes
Accesssing child records Count towards System.limit exception?
In Apex, when a child relationship exceeds a certain threshold (minimum 200, maximum 2,000, depending on number/types of fields queried), the list changes from an ordinary list into a QueryLocator. If ...
1
vote
System.LimitException: Too many Email Invocations: 11
I would do something like this:
{
List<Messaging.SingleEmailMessage> allMails = new List<Messaging.SingleEmailMessage>();
Set<Id> accountIdSet = new Set<Id>();
for(...
1
vote
maximum trigger depth exceeded while updating old child records
Hi I have found the solution for the above issue,
I have handled the recursion by trigger handler class.
Hope this will be helpful for others in future.
Trigger:
trigger ...
1
vote
Accepted
Anonymous Apex - System.LimitException: Too many SOQL queries: 101 - No DML In LOOP?
@kurunve has a point, if you have trigger on Case sObject and you're retrieving about 4k rows, then it definitely can exceed the limit of SOQL queries in one transaction.
Workaround:
Process your ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
limitexception × 46apex × 27
soql × 13
governorlimits × 13
trigger × 9
batch × 5
visualforce × 3
exception × 3
schedulebatch × 3
lightning-web-components × 2
unit-test × 2
api × 2
integration × 2
data-loader × 2
error-messages × 2
singleemailmessage × 2
heapsizelimit × 2
lightning × 1
javascript × 1
rest-api × 1
email × 1
managed-package × 1
visual-workflow × 1
process-builder × 1
case × 1