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
Mayank_SareenMayank_Sareen 

Modification permission--SOQL

Hi all,

I want to allow modification of a record only by specific user using SOQL query. Can this be done? 

Thanks
Mayank.
Best Answer chosen by Mayank_Sareen
Shubham NandwanaShubham Nandwana
Hi Mayank,
we will need “FOR UPDATE” clause of SOQL.

While a sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface. The client locking the records can perform logic on the records and make updates with the guarantee that the locked records won’t be changed by another client during the lock period. The lock gets released when the transaction completes.

To lock a set of sObject records in Apex, embed the keywords FOR UPDATE after any inline SOQL statement. For example, the following statement, in addition to querying for two accounts, also locks the accounts that are returned:
Sample :
Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];​
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm

Mark it as best answer if it helps.

Shubham Nandwana.
AppPerfect Corp.
salesforce@appperfect.com
408-252-4100
http://www.appperfect.com/services/salesforce/
Salesforce Development & Operations Experts