Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [for-update]

The tag has no usage guidance.

0
votes
2answers
46 views

Race condition Soql with order by

I have a lead owner assignment logic with many conditions. When user presses a button "Get lead" a lead in the org is searched and ordered by the field rank (Soql order by rank__c), and when the lead ...
10
votes
1answer
126 views

FOR UPDATE returns old values

I use FOR UPDATE locking in a query but when the first execution completed, the second execution (started while records were locked) seems to use the old data set. I played around for a while and ...
5
votes
2answers
116 views

Pessimistic Lock Released after Callout

The documentation says: The lock gets released when the transaction completes. However I can validate that it also gets released when a callout is made! Here a two test methods: public static ...
11
votes
1answer
1k views

When is a FOR UPDATE lock released?

The Salesforce docs say that The lock gets released when the transaction completes Does that mean when the record is updated, or when the execution context completes?
0
votes
1answer
46 views

Can a web service callout be made in code that has a “for update” lock applied?

I believe a motivation for the platform not allowing DML before a web service callout is to avoid a long-lived transaction (as the callout is allowed to wait up to 10 seconds for its response). I ...
0
votes
1answer
74 views

FOR UPDATE in a Subquery?

I am assigned a POC project to consciously attempt a record and its children from one block of code and the other block of code would try to see how an update on such locked records behave. I am fine ...
11
votes
1answer
1k views

Transaction isolation in Salesforce

As far as I understand Salesforce supports optimistic (by default) and pessimistic (using FOR UPDATE) locking for records. But what about transactions? If there direct analogy for typical SQL ...
40
votes
4answers
11k views

SOQL Record Locking : For Update

Well I was trying to Implement Record Locking apex but Salesforce Document doesn't seem to help much. Even tried searching stackexchange there was a old question but the answer form StackExchange and ...
1
vote
1answer
92 views

Mass field update

Some of my Accounts are known as Ultimate Parents. They are either parent or grandparent to all other Accounts for a particular company. Due to a large data migration, I would like to have the ...
36
votes
1answer
589 views

Help me solve a concurrency mystery (platform bug? Expected behavior? Or am I missing something?)

To set up the problem, add a new currency data type custom field called Test_Counter__c to the Opportunity Object. Then create a test opportunity named TestOp. Then create the following class: ...