0

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 have a query that I want to use a "for update" locking statement in to ensure some processing is only done once. But immediately following that query I want to make a web service callout. It occurs to me that this may also be disallowed by the platform (locking requiring a transaction?) or be potentially problematic but I haven't found any documentation on the subject.

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

2
  • 1
    Should be simple enough to mock up. Get account in a for update DML. Perform a callout immediately after to any random site. Did you give it a shot?
    – Eric
    Aug 20, 2016 at 18:52
  • @Eric This came up in some refactoring so quite soon next week I'll find out. Taking the lazy approach by asking...
    – Keith C
    Aug 20, 2016 at 20:14

1 Answer 1

1

Have now run the code and it is working fine - so the answer is yes.

2
  • I was just going in to mock this up. Glad you got the answer. Although, not sure why SF will not allow DML before a callout. Just provide us a method to commit before a callout so the decision is deliberate on the part of the developer
    – Eric
    Aug 20, 2016 at 23:54
  • Of course, keep in mind that holding any lock longer than necessary can affect other users in the system.
    – sfdcfox
    Aug 22, 2016 at 1:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .