Activity Forums Salesforce® Discussions Can we lock record using soql in salesforce ?

  • Kirandeep

    Member
    April 15, 2020 at 1:16 pm

    Yes , By using “FOR UPDATE” clause of SOQL.
    Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];

  • Marziya

    Member
    April 15, 2020 at 1:27 pm

    Hii Aditya,
    Anyone can get access to it through a standard SOQL query (aka not attempting to lock it) still, but if they attempt to access it with FOR UPDATE as well, the system will return the QueryException blocking both transactions from locking the record. The delay will occur on DML.

  • Pooja

    Member
    April 15, 2020 at 1:39 pm

    Yes , By using “FOR UPDATE” clause of SOQL.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos