0% found this document useful (0 votes)
2K views4 pages

Salesforce Record Locking Guide

This document provides a summary of record locking behavior in Salesforce. It details how common objects and operations lock records to maintain data integrity. Operations on many standard objects like Account, Case, Contact, etc. can lock the parent record. Custom objects may lock records based on field configurations. Large data volumes or batch jobs can cause record locking issues. The cheat sheet is meant to be used additively to determine the full locking impact of a given transaction.

Uploaded by

swetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views4 pages

Salesforce Record Locking Guide

This document provides a summary of record locking behavior in Salesforce. It details how common objects and operations lock records to maintain data integrity. Operations on many standard objects like Account, Case, Contact, etc. can lock the parent record. Custom objects may lock records based on field configurations. Large data volumes or batch jobs can cause record locking issues. The cheat sheet is meant to be used additively to determine the full locking impact of a given transaction.

Uploaded by

swetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Object-Specific Locking Behavior
  • Overview
  • Custom Configuration Locking Behavior
  • Sharing Operation Locking Behavior

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 roll-up 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:
1. Opportunity inserts lock the related account record
2. The roll-up summary field also locks the related account record
3. The lookup may lock the lookup record depending on its configuration

Object-Specific Locking Behavior


Login and Authentication features and restrictions. These settings should be enabled as appropriate for your company.
Risk of Lock
Focus Operation Locks Detail
Contention
Updating locks target record and may
Updated record, sharing result in the creation and/or deletion
Any record Update Low
records of one or more sharing records in a
private sharing model.

Deleting locks the record being


Record being deleted,
Delete deleted and one or more sharing Low
sharing records
records in a private sharing model.

Lock occurs if updating the owner field


Account Update / Delete Group Table of, or deleting, an Account that has High
associated community or portal roles.

AccountTeamMember inserts,
updates and deletes can result in
the creation and deletion of child
implicit shares on Cases, Contacts and
Opportunities but associated object
AccountTeamMember, Associated Account, records are not locked.
Insert / Delete High
CaseTeamMember, Case, or Opportunity 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.

Associated Campaign,
CampaignMember Insert / Update High
Contact or Lead

Case Insert / Update / Delete Account, Contact High

Contact Insert / Update Parent Account High

Event Insert / Update / Delete Who, Account High

Locks on What occur if the What has a


What LastActivityDate field or it is related to High
an Account.

Inserting or deleting group members


GroupMember Insert / Delete Group Table High
and territory members causes lock.
Record Locking Cheatsheet

Object-Specific Locking Behavior (Continued)


Risk of Lock
Focus Operation Locks Detail
Contention

Opportunity Insert / Update / Delete Parent Account High

Locks only occur if the Status is Completed


Task Insert Who, What, and Account High
and the ActivityDate is not null.

Update / Delete Who, What, and Account High

Insert / Delete / Reparent


Territory / Add or remove User Group Table High
from Territory

Requires non-null UserRoleId on insert.


User Insert / Update Group Table High
Requires UserRoleId change on update.

UserRole Insert / Delete Group Table High

Reparent (includes changing portal


account owner and updating the
Update Group Table High
UserRole of a user that owns a portal
account)

Custom Configuration Locking Behavior


Risk of Lock
Focus Operation Locks Detail
Contention

SELECT FOR UPDATE Locks all records retrieved in SELECT


Any record Selected records High
SOQL query statement that uses FOR UPDATE.

Detail record of Master-


Insert / Delete Master record High
Detail relationship

Update master record ID Master record High

Locks only occur if lookup


Record with a lookup Insert new record with relationship is not configured to
Lookup record High
relationship lookup value clear the value of this field if the
lookup record is deleted.

Locks only occur if lookup relationship is


Update record and change
Lookup record not configured to clear the value of this High
lookup value
field if the lookup record is deleted.

Master record(s) locked regardless of


whether the roll-up summarys target
Record with a roll-up Insert / Update / Delete field has a value or the value has
Master record(s) High
summary field detail record changed during an update. This behavior
is the same on a roll-up summary on a
standard object, such as Account.

Record being updated Only workflow rules that trigger a


Workflow Workflow field update High
by workflow field update will lock.
Sharing Operation Locking Behavior
Risk of Lock
Focus Operation Locks Detail
Contention

Results in addition/removal of object


share records based on previous
Sharing rule Modify sharing rule Object share records Low
definition of rule. Object records are
not locked.

Results in addition/removal of object


Org-wide defaults Modify org-wide defaults Object share records share records. Object records are Low
not locked.

AccountShare, CaseShare, Results in addition/removal of object


Account assignment
Run assignment rules ContactShare, share records. Object records are Low
rules
OpportunityShare not locked.

Can result in creation / deletion of child


CaseShare, ContactShare,
AccountShare Insert / Update / Delete implicit shares. Object records are Low
OpportunityShare
not locked.

Can result in creation / deletion of


CaseShare Insert / Update / Delete AccountShare parent implicit share. Existing shares Low
are not locked.

Can result in creation / deletion of


ContactShare Insert / Update / Delete AccountShare parent implicit share. Existing shares Low
are not locked.

Can result in creation / deletion of


OpportunityShare Insert / Update / Delete AccountShare parent implicit share. Existing shares Low
are not locked.

Role-based portal user Provision Group Table High

Follow Us Related Resources


Twitter On Architect Core Resources:
[Link]/architect
[Link] - @forcedotcom
"Designing Record Access for Enterprise Scale"
Steve Bobrowski - @sbob909
"Record-Level Access: Under the Hood"
Daisuke Kawamoto - @DaisukeSfdc
"The Salesforce Bulk API - Maximizing Parallelism and Throughput
Sean Regan - @SFDCSRegan Performance When Integrating or Loading Large Data Volumes"

Markus Spohn - @markus_spohn On the Salesforce Developers Blog:


[Link]/blogs
John Tan - @johntansfdc
"Locking Down Record Access in Salesforce"
Bud Vieira - @aavra
"Managing Lookup Skew in Salesforce to Avoid Record Lock
Facebook + LinkedIn Exceptions"

[Link]/forcedotcom "Reducing Lock Contention by Avoiding Account Data Skew"

[Link]/groups/Developer-Force-Forcecom- "Group membership operation already in progress


Community-3774731 Managing Group Membership Locks for Success"
[Link]

For other cheatsheets:


[Link] 10042016

You might also like