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)

  • 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 '14 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 – Brent Bow Mar 15 '17 at 5:17
3

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.

  • 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)? – Matthew Lamb Mar 20 '14 at 15:27
  • None that I've heard about - I don't recall ever reading of differences. – Bob Buzzard Mar 20 '14 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... – Matthew Lamb Mar 20 '14 at 16:57
  • Great spot. Interesting that its not mentioned in the managing lookup skew document. – Bob Buzzard Mar 20 '14 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). – Brent Bow Mar 15 '17 at 5:22
0

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 - when 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 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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.