function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
durga prasad 45durga prasad 45 

loking records

can any one give how to lock the records from one user to another user while updating 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post i hope that will help you
1) http://amitsalesforce.blogspot.com/2015/03/locking-statements-for-update.html

Apex allows you to lock sObject records while they’re being updated in order to prevent race conditions and other thread safety problems. While an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface.
Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
NOTE:-
While the records are locked by a client, the locking client can modify their field values in the database in the same transaction. Other clients have to wait until the transaction completes and the records are no longer locked before being able to update the same records. Other clients can still query the same records while they’re locked.
If you attempt to lock a record currently locked by another client, you will get a QueryException. Similarly, if you attempt to update a record currently locked by another client, you will get a DmlException.
If a client attempts to modify a locked record, the update operation might succeed if the lock gets released within a short amount of time after the update call was made. In this case, it is possible that the updates will You can’t use the ORDER BY keywords in any SOQL query that uses locking


 
Rupal KumarRupal Kumar
hi durga prasad,
                   See this link--https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm
                                         http://www.asagarwal.com/2426/how-to-lock-records-in-salesforce
                                          https://developer.salesforce.com/forums/?id=906F00000008kfkIAA


Thanks
Rupal 
Mirketa Software Pvt Ltd
http://mirketa.com/index.html