System.LimitException: Apex CPU time limit exceeded


Salesforce has a timeout limit for transactions based on CPU usage. If transactions consume too much CPU time, they will be shut down as a long-running transaction.

When you receive this error, this means that the task you are running on is triggering some APEX code on your Salesforce Organization and that APEX code is causing the CPU time limit to be exceeded and therefore the job is stopped.


First of all, you should take a look to Salesforce documentation "Code more efficiently to avoid 'Apex CPU time limit exceeded'". The best option would be to improve your code to avoid the error.

In case you are not able to improve your code then another option is to use the Batch API when running your task and if needed, reduce the batch size until the error is avoided.

Notice that the bigger the batch is, the more time it will take to be processed on Salesforce side and therefore the limit can be reached. Bulk API uses big batches and their size cannot be changed while Batch API allows you to set batch size from 1 to 200.

To select which API to use and batch size you should edit your task and go to the last step of the task wizard. There you will find the option to select "API Mode" to opt between Bulk or Batch API. If you select Batch API you can set the batch size (1 to 200). The size is the number of records that will be send per request.

Notice that setting smaller batch sizes will cause to need more API requests so you should ensure you won't reach the API requests limit for your Salesforce Organization.

Have more questions? Submit a request


  • Avatar
    Hugo Rodriguez

    el batch es de ese perro tamaño y no jala vayanse alv

    Comment actions Permalink

Please sign in to leave a comment.