11

Does salesforce lock Account Record when user try to update/create following child objects -

  1. AccountTeamMember

  2. Opportunity Line Item (Does sfdc lock opportunity here as well?)

  3. Task

  4. Contact

  5. OpportunityTeamMember (Does sfdc lock opportunity here as well?)

Is this applicable to only Master Detail relationships ? (Not Lookups)

2
  • 6
    I believe Salesforce locks any parent record in which a M-D relationship is causing a rollup summary field to rollup. There are some implied rollups too, like CampaignMember to Campaign.
    – greenstork
    Feb 5, 2014 at 17:55
  • @greenstork This is true, though rollup summaries are only relevant for the update scenario. On insert or delete of a detail record, the master record is always locked. Documentation Reference Mar 15, 2017 at 5:17

2 Answers 2

4

This applies to lookup fields as well as master detail fields - check out the Lookup Skew section of this blog post:

http://blogs.developerforce.com/engineering/2013/04/managing-lookup-skew-to-avoid-record-lock-exceptions.html

The key statement is:

Every time a record is inserted or updated, Salesforce must lock the target records that are selected for each lookup field; this practice ensures that, when when the data is committed to the database, its integrity is maintained.

5
  • Are there any performance considerations to be made between Lookup and Master-Detail, or between the configuration of each of those (e.g. required vs. optional lookups, re-parentable M:D)? Mar 20, 2014 at 15:27
  • None that I've heard about - I don't recall ever reading of differences. Mar 20, 2014 at 16:35
  • Actually I just found this (wiki.developerforce.com/page/…), which suggests that the "What to do if the lookup record is deleted?" setting has a strong impact on locking behavior for lookups. Off to do some testing... Mar 20, 2014 at 16:57
  • Great spot. Interesting that its not mentioned in the managing lookup skew document. Mar 20, 2014 at 17:17
  • @BobBuzzard parent records in Lookup relationships with an updated child record are only locked when the Lookup value on the child changes. Also, whether the child record is inserted or updated, Lookup parent records are only locked "if [the] lookup relationship is not configured to clear the value of this field if the lookup record is deleted," which is the default option (clearing the value, that is). Mar 15, 2017 at 5:22
2

The place you're going to want to start for investigating all record-lock contention issues is Salesforce's Record Locking Cheat Sheet.

It succinctly answers each of the questions from the OP:

  1. AccountTeamMember - Yes.
  2. Opportunity Line Item - If it updates the Opportunity, yes.
  3. (Does sfdc lock opportunity here as well?) Yes. (as with Master-Detail relationships)
  4. Task - Yes on update/delete; on create, only if the Status is Completed and the ActivityDate is not null.
  5. Contact - Yes.
  6. OpportunityTeamMember - No.
  7. (Does sfdc lock opportunity here as well?) - Yes.

As for the OP's final question:

Master Details: On insert or delete of a detail record, the master record is always locked. On update, the master is only locked if rollup summary fields exist on the master for that child type.

Lookups: On update of children, parent records are only locked when the Lookup value on the child changes. On insert or update, parent records are only locked "if [the] lookup relationship is not configured to clear the value of this field if the lookup record is deleted," which is the default option (clearing the value, that is).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .