How can I synchronize a flow that updates a record with the email panel? Or make the flow run synchronously so that the user waits for it to finish?

I have a meeting note object with 3 junctions relating it to contacts, staff and topics discussed at the meeting. I created a process which has an immediate action that calls a flow. The flow rounds up the names of those records and puts them into a mail merge data field on the meeting record. The user will save a meeting note, then will click on the Activity > Email panel, selecting an email template that will include the mail merge field.

I am seeing what looks like a race condition. Sometimes if you click the preview eye button it does not pick up all the contacts or staff who attended the meeting. I see that when the email is sent too. If I re-save the meeting note and do it again it works.

I would like the flow to run synchronously and the Meeting Note saved alert message should not appear until it is done. Any ideas on how to synchronize the email with a different field I can mark when the flow is done?

See the screenshots below. I get no fault emails despite setting them up on all DML elements. I added several attendees, saved, then sent the email right away, getting blank attendees. I waited 5-10 minutes but still the field was not updated. Now I open the record to edit and hit save again, and the field has been updated. (see final screenshot showing all attendees.)



Blank attendees (I added several hit save then sent email right away. But it never actually updates the merge field at all.

Full attendees (resaved, now it works)

2 Answers 2


If your flow is called in an immediate action in process builder and does not have any wait elements, it runs synchronously.

It will be part of the same transaction as the save of the record.

After save, your field will be populated, as the save cannot complete until the flow is finished.

If you believe you are seeing this issue in spite of setting it up as an immediate action, I would post screenshots of your flow and process.

Are there other flows or workflows or processes running that are setting some of the fields the flow relies on? Perhaps there is an order of operations issue.

  • No other flows or processes affect those fields. I posted screenshots. Not sure it is race condition, but I added send error email actions to all DML elements and no email was received.
    – skycafe
    Jul 2, 2019 at 5:47
  • p.s. yes, it is an immediate action. So the flow is quietly failing it seems, but I cannot see where and none of the fault flows are being triggered.
    – skycafe
    Jul 2, 2019 at 5:57
  • I think what is happening is that the flow is not being executed in the same transaction. If I add several contacts at once it must be taking a while to save it all, and the flow runs without seeing them yet. I will try inserting it into the apex class that does the saving.
    – skycafe
    Jul 2, 2019 at 6:35
  • I would start by using the debugger within the flow to step through and see what the issue is. If the flow was failing you should receive an error email as well w the details. You also can use the debug logs to see the flow start and end. The flow will run in the same transaction, that has never been an issue and I have large flows. If you hit a limit then you will get an error, but if you are within limits the flow will complete in the same transaction.
    – gorav
    Jul 4, 2019 at 19:16
  • Thank you. I resolved it by running the flow from my code, which I did not want to do (had to give users Run Flow permissions) but no error was thrown by the flow and I added error code to every statement. Thanks for your help but will close this for now.
    – skycafe
    Jul 7, 2019 at 9:45

The answer I found is that you cannot trust Salesforce's timing. I think this is a bug in Salesforce platform. (Second one I found just on this project.)

Even though the Process was set for Immediate action on update, it actually appears to execute a fixed amount of time after the transaction starts.

I was able to reproduce the error by adding ten different objects associated by junctions to the meeting note. Every time, the flow launched by the process would fail to pick them up. It worked most of the time when there were only a small number of linked objects.

The answer was to not use a Process, instead call the Flow directly from the program. I did not want to add it to the Apex transaction code because the flow would add another potential point of failure, and mail merge is not as important as making sure the data is saved.

Therefore I called the flow from the Javascript controller after it displays the success (Meeting Note xxx was saved) toast message. I also added the flow to the lightning component.

In cmp file:

<lightning:flow aura:id="mailMergeFlowData" /> 

In JS file:

saveRecords.setCallback(this, function(data) {
  if(data.getState() === "SUCCESS" && data.getReturnValue().indexOf("a00") === 0){ 
component.set("v.status", "success");

var thenewmeetingnoteid = data.getReturnValue();
component.set("v.messages", "Meeting Note \"" + meetingNoteName + "\" was saved.");
helper.showToast("success", "pester", "Meeting Note \"" + meetingNoteName + "\" was saved.");

var theFlowAPIName = "Meeting_Note_mail_merge_data_field_update_Call_from_Controller";

// Find the component
var flow = component.find("mailMergeFlowData");
// set flow input parameters
var flowinputvars = [
  {name: "varMeetingNoteId", type: "String", value: thenewmeetingnoteid}
// In that component, start the flow to refresh the mail merge data field
flow.startFlow(theFlowAPIName, flowinputvars);

} else { // An error occurred
   component.set("v.status", "error");
   component.set("v.messages", data.getReturnValue());

You must log in to answer this question.

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