Loading

Salesforce Field Service: Book Appointment Action or GetSlots API Causing "APEX CPU Time Limit Exceeded" Error

Udgivelsesdato: May 12, 2026
Beskrivelse

In Salesforce Field Service (SFS), the Book Appointment action and the GetSlots Application Programming Interface (API) can trigger an "APEX CPU Time Limit Exceeded" error.
This error occurs when the system performs a synchronous (sync) Apex operation — which is limited to 10 seconds — and the computation exceeds that threshold. The error is most commonly encountered when:

  • The scheduling horizon is set too large (too many days to search for candidates)
  • Debug or trace logging is active during the operation
  • The Service Appointment (SA) uses synchronous logic instead of asynchronous (async) logic
Løsning

To resolve the "APEX CPU Time Limit Exceeded" error in Salesforce Field Service when booking an appointment or using the GetSlots API, apply one or more of the following performance improvements:

Option 1: Limit the Scheduling Horizon

Navigate to: Field Service Settings > Scheduling > Maximum days to get candidates or to book an appointment.
Increasing this value decreases performance and can trigger the APEX CPU Time Limit Exceeded error. Set this value as low as your business requirements allow.

Option 2: Switch to Async Logic

Use the "Use Async Logic" field on the Service Appointment (SA) record to switch from a synchronous operation (Apex CPU limit: 10 seconds) to an asynchronous operation (limit: 60 seconds). This significantly reduces the risk of hitting the CPU limit.

Option 3: Enable Limit Apex Operations

Navigate to: Field Service Settings > Scheduling > Limit Apex Operations.
Enabling this feature prevents the system from exceeding the CPU limit by stopping before all optional slots are evaluated. Note: this may result in fewer candidate slots being returned.

Option 4: Reduce Debug Tracing Level

Turn down your debug log level to an absolute minimum. Do not use active tracing unless it is absolutely necessary for active troubleshooting, as debug logging significantly increases CPU usage.

Yderligere ressourcer
Vidensartikelnummer

000395654

 
Indlæser
Salesforce Help | Article