1

I have a screen flow that is included in a lightning record page. At some point it executes a callout to an external system. The scenario that I would need to avoid is to have multiple users open the flow and execute the callout at the same time.

The only way to avoid this that came to mind is the following:

  • Create a new custom field on the object, that will be used as a flag;
  • Query the flag when the flow gets opened;
  • When the callout gets executed, send the value of the flag from the flow to the controller;
  • Before the callout gets executed, query the flag from the database and check if it's different from the value sent from the flow. If it is, then the callout has been executed already by another user;
  • After checking if the flag got changed(but before the callout), update the flag to the current date time;

The problem that I am facing is the fact that the callout needs to be executed synchronuously, but the DML needs to be executed before the callout. Still, since DMLs cannot be executed before callouts, I'm pretty much stuck at this point.

How can I avoid having the same flow element being executed in parallel by multiple users?

0

Rather than using DML to update field values, you can use Platform cache to store the flag and you can easily retrieve before making the callout.

Good thing is, it is not counted against DML and no issue for callout and saving to cache.

Refer Store and Retrieve Values from the Org Cache to utilize it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.