Resolving Apex CPU Time Limit Exceeded Errors

Last updated

The “Apex CPU time limit exceeded” error points to Plauti Assign, but all Apex code in the transaction counts toward the limit. This article explains why and how to find the cause.

You may see the error leadassist.assignLead: System.LimitException: Apex CPU time limit exceeded or similar when you create or update records in Salesforce. The error points to Plauti Assign (leadassist), but that does not always mean Plauti Assign is the main cause. This article explains how Salesforce counts Apex CPU time and what to check to resolve the error.

How Salesforce counts Apex CPU time

Salesforce limits the CPU time that a single transaction can use. This prevents one process from using too many shared resources and slowing down other users and orgs. The limit is 10,000 milliseconds (10 seconds) for synchronous transactions and 60,000 milliseconds (60 seconds) for asynchronous transactions.

CPU time is counted for the whole transaction, not per feature. Plauti Assign uses part of the limit, and so does every other automation that runs in the same transaction, such as:

  • Apex triggers
  • Flows
  • Processes built with Process Builder
  • Workflow rules
  • Validation rules

When the total reaches the limit, Salesforce stops the transaction and shows the error. The error message names the Apex code that was running at that moment, which is often Plauti Assign (leadassist). Plauti Assign does contribute to the total, but the other automation may contribute as much or more.

Salesforce plans to retire Process Builder and Workflow Rules, and recommends building new automation in Flow Builder instead. Both are still available in Salesforce Setup though, so they can still contribute to CPU time in your org.

Resolving the error

To resolve the error, find out which automation uses the most CPU time in the transaction, and then optimize it.

  • Reduce the batch size. Large batches multiply the CPU time of each record. For example, if processing one record takes 60 ms and you import 200 records in one batch, the transaction needs 12,000 ms and exceeds the synchronous limit of 10,000 ms.
  • Capture debug logs. In Salesforce Setup, open Debug Logs and capture a log of a transaction that fails or runs slowly. Analyze the log to see which automation uses the most CPU time. Contact Plauti Support if you want help capturing and analyzing a log related to Plauti Assign.
  • Review other automations. Check the Apex triggers, flows, processes, and workflow rules on the object involved. Temporarily deactivate them, preferably in a sandbox, to see how this changes the result.