Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

How to Prevent UNABLE\_TO\_LOCK\_ROW Errors When Creating Tasks

公開日: Oct 16, 2025
タスク

You want to prevent UNABLE\_TO\_LOCK\_ROW errors that occur when tasks are being created or updated in Salesforce.

ステップ
  1. Reduce Concurrent Operations: Limit the number of users or automated processes that are trying to update the same record at the same time.
  2. Optimize Apex Code and Flows: Review any Apex triggers, flows, or workflow rules that run on task creation or update. Ensure they are efficient and do not perform excessive database operations or complex calculations that could lead to contention.
  3. Use `FOR UPDATE` Sparingly: If you have custom Apex code, avoid using `SELECT... FOR UPDATE` unless absolutely necessary, as it explicitly locks records.
  4. Implement Retry Logic: For batch processes or integrations, implement retry logic with exponential back-off to handle temporary locking errors gracefully.
  5. Break Down Large Transactions: If you are inserting or updating a large number of tasks, consider processing them in smaller batches to reduce the chances of record locking.
  6. Review Parent Record Locking: The Task object's WhoId (Contact/Lead) and WhatId (Account/Opportunity/etc.) fields link it to a parent record. Locks on the parent record are the most common cause of UNABLE_TO_LOCK_ROW errors during task creation, especially if multiple tasks are created simultaneously against the same parent record.
  7. Check for External System Integrations: If external systems are creating or updating tasks, ensure their integration logic accounts for Salesforce's locking mechanisms and implements appropriate error handling or retry strategies.
  8. Monitor Performance and Debug Logs: Regularly check Salesforce's debug logs for "UNABLE\_TO\_LOCK\_ROW" messages to identify specific triggers or processes that are causing the errors. Analyze the stack trace to pinpoint the problematic code or configuration.
  9. Consider Queueable Apex or Batch Apex for Asynchronous Operations: For operations that don't require immediate processing, use asynchronous Apex features like Queueable Apex or Batch Apex to offload work and reduce synchronous locking conflicts.
ナレッジ記事番号

005226737

 
読み込み中
Salesforce Help | Article