If you’ve received a notification that an error message has generated and it references that “Apex CPU time limit exceeded”, this article will help you understand the issue.
Does the error message look similar to the below example?
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: LeanData.BeforeLeadUpdate: System.LimitException: Apex CPU time limit exceeded.
If your error message is similar to this, your Salesforce instance likely has too many synchronous processes running in in your trigger code.
Why is LeanData mentioned in the error?
Salesforce limits CPU time for every transaction to 10 seconds. This limit is shared by all processes running in the trigger code, so Apex CPU timeouts are a group effort. The package that happens to be running at the moment the time limit is exceeded gets called out on the error, regardless of how much or how little of the 10 second limit it may have consumed.
So while LeanData trigger code contributes to this, there are other processes that also contribute and may be consuming a much greater portion of the CPU time.
What can I do?
If you are converting a large number of records through your routing configuration ask LeanData support if reducing the batch size might be an option.
Consider using future calls and asynchronous processing instead of synchronous processing in the trigger code
Disable any unnecessary Process Builder flows if possible.
Audit the Apex code you may running to ensure it is efficient. One way to do this is by capturing debug logs which you can send to LeanData Support to review. Please see the Capturing Debug Logs article for instructions on how to do this.
Consider Salesforce best practices for Triggers and Bulk Requests
Questions? Contact LeanData Support