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
Sadish KumarSadish Kumar 

Record Locking "For Update"

Hi Guys - I'm using a 'For Update' in my SOQL query in awebservice method and i'm getting an error message "Error: Compile Error: SObject type does not allow locking rows at line ". Can someone let me know whats the problem here !!!

My Code :
*****
global class recordLocking { 
    webService static Boolean lockmyrecord(String idUser) {
        Boolean val = false;
        User obj = null;
        obj = [SELECT Id FROM User WHERE Id = :idUser LIMIT 1 FOR UPDATE]; 
        return (val);
    }
}
*****


 
ndrannapareddyndrannapareddy
The values has to be stored in a collection to lock


User[] obj = [SELECT Id FROM User WHERE Id = :idUser LIMIT 1 FOR UPDATE]; 

use the First element when using the record.


 
Sadish KumarSadish Kumar
Still not working for me

.User-added image