SF Record Locking Cheatsheet Web
DOWNLOAD
First things first !
To download this implementation guide, click the download button below.
If you need more information about the implementation guide, you can read the Table of Contents below.
Record Locking
Cheatsheet
Overview
Similar to any application built on a relational database the Salesforce platform uses locks to ensure referential integrity of its data Most transactional
database operations only hold these locks for a very short period of time and the volume is not significant enough to cause contention However
when dealing with large data volume objects or processing large jobs record locks and contention can become an issue This cheat sheet details the
behavior of objects that cause the most common locking issues
Using this Cheatsheet
This cheat sheet is additive in nature so you must consider all rows when determining the locking behavior of a particular object and operation
For example if you are performing an insert of an opportunity record and you have a rollup summary field on the account object and a lookup
to a custom object you would need to look at the following three rows in the cheat sheet
Opportunity inserts lock the related account record
The rollup summary field also locks the related account record
The lookup may lock the lookup record depending on its configuration
ObjectSpecific Locking Behavior
Login and Authentication features and restrictions These settings should be enabled as appropriate for your company
Focus
Any record
Account
Operation
Locks
Detail
Risk of Lock
Contention
Update
Updated record sharing
records
Updating locks target record and may
result in the creation andor deletion
of one or more sharing records in a
private sharing model
Low
Delete
Record being deleted
sharing records
Deleting locks the record being
deleted and one or more sharing
records in a private sharing model
Low
Update Delete
Group Table
Lock occurs if updating the owner field
of or deleting an Account that has
associated community or portal roles
High
AccountTeamMember inserts
updates and deletes can result in
the creation and deletion of child
implicit shares on Cases Contacts and
Opportunities but associated object
records are not locked
AccountTeamMember
CaseTeamMember
Insert Delete
Associated Account
Case or Opportunity
CampaignMember
Insert Update
Associated Campaign
Contact or Lead
High
Case
Insert Update Delete
Account Contact
High
Contact
Insert Update
Parent Account
High
Event
Insert Update Delete
Who Account
High
GroupMember
Insert Delete
CaseTeamMember and
OpportunityTeamMember inserts
deletes can result in the creation or
deletion of a parent implicit account
share however existing parent implicit
shares are not locked
High
What
Locks on What occur if the What has a
LastActivityDate field or it is related to
an Account
High
Group Table
Inserting or deleting group members
and territory members causes lock
High
Record Locking Cheatsheet
ObjectSpecific Locking Behavior Continued
Focus
Operation
Locks
Detail
Risk of Lock
Contention
Opportunity
Insert Update Delete
Parent Account
Task
Insert
Who What and Account
Update Delete
Who What and Account
High
Territory
Insert Delete Reparent
Add or remove User
from Territory
Group Table
High
User
Insert Update
Group Table
UserRole
Insert Delete
Group Table
Update
Group Table
High
Locks only occur if the Status is Completed
and the ActivityDate is not null
Requires nonnull UserRoleId on insert
Requires UserRoleId change on update
High
High
High
Reparent includes changing portal
account owner and updating the
UserRole of a user that owns a portal
account
High
Custom Configuration Locking Behavior
Focus
Operation
Locks
Detail
Any record
SELECT FOR UPDATE
SOQL query
Selected records
Detail record of MasterDetail relationship
Insert Delete
Master record
High
Update master record ID
Master record
High
Record with a lookup
relationship
Insert new record with
lookup value
Update record and change
lookup value
Locks all records retrieved in SELECT
statement that uses FOR UPDATE
Risk of Lock
Contention
High
Lookup record
Locks only occur if lookup
relationship is not configured to
clear the value of this field if the
lookup record is deleted
High
Lookup record
Locks only occur if lookup relationship is
not configured to clear the value of this
field if the lookup record is deleted
High
High
High
Record with a rollup
summary field
Insert Update Delete
detail record
Master records
Master records locked regardless of
whether the rollup summarys target
field has a value or the value has
changed during an update This behavior
is the same on a rollup summary on a
standard object such as Account
Workflow
Workflow field update
Record being updated
by workflow
Only workflow rules that trigger a
field update will lock
Sharing Operation Locking Behavior
Focus
Operation
Detail
Locks
Risk of Lock
Contention
Sharing rule
Modify sharing rule
Object share records
Results in additionremoval of object
share records based on previous
definition of rule Object records are
not locked
Orgwide defaults
Modify orgwide defaults
Object share records
Results in additionremoval of object
share records Object records are
not locked
Low
Account assignment
rules
Run assignment rules
AccountShare CaseShare
ContactShare
OpportunityShare
Results in additionremoval of object
share records Object records are
not locked
Low
AccountShare
Insert Update Delete
CaseShare ContactShare
OpportunityShare
Can result in creation deletion of child
implicit shares Object records are
not locked
Low
CaseShare
Insert Update Delete
AccountShare
Can result in creation deletion of
parent implicit share Existing shares
are not locked
Low
ContactShare
Insert Update Delete
AccountShare
Can result in creation deletion of
parent implicit share Existing shares
are not locked
Low
OpportunityShare
Insert Update Delete
AccountShare
Can result in creation deletion of
parent implicit share Existing shares
are not locked
Low
Rolebased portal user
Provision
Group Table
Follow Us
Twitter
Forcecom forcedotcom
Steve Bobrowski sbob
Daisuke Kawamoto DaisukeSfdc
Sean Regan SFDCSRegan
Markus Spohn markusspohn
John Tan johntansfdc
Bud Vieira aavra
Low
High
Related Resources
On Architect Core Resources
developersalesforcecomarchitect
Designing Record Access for Enterprise Scale
RecordLevel Access Under the Hood
The Salesforce Bulk API Maximizing Parallelism and Throughput
Performance When Integrating or Loading Large Data Volumes
On the Salesforce Developers Blog
developersalesforcecomblogs
Locking Down Record Access in Salesforce
Facebook LinkedIn
Managing Lookup Skew in Salesforce to Avoid Record Lock
Exceptions
wwwfacebookcomforcedotcom
Reducing Lock Contention by Avoiding Account Data Skew
wwwlinkedincomgroupsDeveloperForceForcecomCommunity
Group membership operation already in progress
Managing Group Membership Locks for Success
developersalesforcecom
For other cheatsheets
httpdevelopersalesforcecomcheatsheets