function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vincent Drader 2Vincent Drader 2 

How to use Flow to create multiple duplicate records with static values?

Hi all - I'm trying to create a Flow that would create duplicate records in a custom object we have. I want to walk my users through screens to be able to input a few values, then they'd enter a "how many duplicate records do you want to create?" question. For instance, they may say 20, and then it would create 20 duplicate records with all the field values they assigned. Easy way to do this in Flow?
 
Best Answer chosen by Vincent Drader 2
Gaurav HandooGaurav Handoo
Hi Vincent

Assuming that you have your input screens handled (values assigned to corresponding varibales for processing). Once you ask your user for counter of duplicate do the following:
  1. Assign it to number variable
  2. Start a decision loop to check if the value of variable is not 0
    1. , assign all the values (from the variables in your previous screens) to an SObject (if not already done)
    2. Assign those to Sobject Collection (this would your first step in case you have done the above step before starting the decision loop)
    3. Use the assignment element to reduce the counter of number variable by 1
    4. Connect back to decision loop
  3. As soon as the counter in the third step reaches 0, it will break out of the decision loop
  4. Next would be to do a fast create to insert the duplicate record defined number of times.
Hope this helps. Let know in case you need any further assistance, you can connect with me at gaurav.handoo@gmail.com.

Cheers!!

Gaurav