0

I have a record-triggered flow which runs when a record is created and it calls an autolaunched flow where it does some record creation on a custom object only if the record does not exist. If a record exists then it should return the id of the existing record.

When I have three records created what should happen is, for each record the autolaunched flow should check if the record exists or not before creating a new record.

But the issue I am seeing here is for each record the autolaunched flow is creating a new record. It does not check if a record exists when the second and third record are created.

For the second and third records I am expecting the id of the existing record to be returned.

Here is the start of my record triggered flow where I am calling a subflow - enter image description here

Here is the start of the Subflow - Here it runs the Create Invoice for Today node thrice instead of just once which would be for the first record and for the second and third it should run the Return Todays Invoice ID node. enter image description here

Here are the debug logs. It says the Invoice Today Exist decision is false always - enter image description here

2
  • so, you are saying that the first interview creates the custom object but the second and third interview don't realize that the custom object was created by the first interview?
    – cropredy
    Commented May 28 at 22:29
  • @cropredy That's right. The first interview creates the custom object record and the second and the third interview does seem to find it at all.
    – Sumesh
    Commented May 28 at 22:54

1 Answer 1

0

Flow Interviews run in logical parallel, collapsing only to a bulkified operation on certain elements. So, interview 2 and 3 can't know what is happening on interview 1.

The workaround is to delegate to invocable apex which can get the inputs from all requests (interviews) at once, de-dup, do the DML, and respond with the Id for interviews 1, 2, and 3

From the doc

When multiple interviews for the same flow run in one transaction, each interview runs until it reaches a bulkifiable element. Salesforce takes all the interviews that stopped at the same element and intelligently executes those operations together. If other interviews are at a different element, Salesforce then intelligently executes those operations together. Salesforce repeats this process until all the interviews finish.

Bulkifiable elements are:

Elements that create, update, or delete records

When a record is created, updated, or deleted, the transaction performs a DML statement.

  • Create Records elements
  • Update Records elements
  • Delete Records elements

Quick Action, Post to Chatter, or Submit for Approval core actions

Apex Action elements—depending on the specific Apex action>

Elements that look up records When fields on a record are looked up, the transaction performs a SOQL query.

  • Get Records elements
  • Update Records elements
  • Delete Records elements

Apex Action elements—depending on the specific Apex action>

Elements that send emails

  • Send Email core actions
  • Email Alert elements
  • Apex Action elements—depending on the specific Apex action

You must log in to answer this question.

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