+ Start a Discussion
Krishna Prasad K PKrishna Prasad K P 

Understanding the record locking.

I have 4 questions on record locking:
  1. Does attaching a file lock the parent record?
  2. I have a Master object record M1 and detail records D1 and D2. When I update D1 and D2, I understand that the M1 gets locked. I have 2 sub questions on it.
    1. I am updating D1 and D2, So the execution order goes through Before update Trigger, actual DML, after update trigger, Workflow field updates etc. So my question is, does M1 get locked from beginning to end till WF field update, or only while the actual update on D1 and D2 into DB (means after BEFORE UPDATE trigger and before AFTER UPDATE trigger)?
    2. Probably related to Q 2.1:  In my AFTER UPDATE trigger context of D1 and D2 update, I wanted to insert one more detail record D3 under the same master M1. Will I get "unable to lock row : M1" error ? 
    3. In my AFTER UPDATE trigger context on child object can I update some field of the master record?