Skip to main content
Va Na 提问于 #Flow

Hello,

I have created a Scheduled Triggered Flow that runs daily to target clients with overdue payments and send them an enhanced SMS.

Before sending the SMS, there is a condition:

  • if the Messaging User does not exist, the flow creates it and then sends the SMS;
  • if it already exists, the flow reuses the existing Messaging User and sends the SMS.

The issue I am facing is that, within the same batch execution, some clients can have multiple overdue payments. As a result, the flow attempts to send two SMS messages, who is the correct way but tries to create the same Messaging User twice, which leads to a duplicate error.

My questions are:

  1. If a Scheduled Triggered Flow encounters an error during execution, does Salesforce automatically retry or rerun the flow?
  2. Is there a recommended Salesforce approach to ensure that, within the same batch, the flow detects that a Messaging User has already been created and reuses it instead of attempting to create a duplicate?

Thank you in advance for your help. 

1 个回答
  1. 2月16日 23:44

    @Va Na

    ,  

    1. No retry/rerun is does not natively occur when Flow fails 

     

    2. Some options. 

    a)  

    - Create a new collection,  

    - Check this collection before creating a new one to avoid duplicates.  If not in the collection, create the new Messaging User and then add it to the collection.  

     

    b) This should be easier/faster: 

    - Create new string variable PriorValue, default blank. 

    - Sort your Get Records so you retrieve/process them in order of client record ID. 

    - in your logic that checks for a messaging user, also check if the current looped record is the same as PriorValue and if so, do NOT create a Messaging User as you have already processed this client at least once before.  If the values don't match, it means you've never processed this client yet, so you can create a Messaging User if needed. 

    - The last step of looping clients should always set PriorValue to the current looped client ID. 

     

    Please mark this as best answer and good luck.