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
Tai RahmanTai Rahman 

Create records based on parent using flows

Hello,

I'm trying to build a flow on Salesforce flow that would create a series of 11 opportunity records based off of a parent record. The only difference between the parent and duplicate records would be the close dates, i.e., if the parent record had a close date of 6/30/20, then the flow would create a series of 11 duplicates with close dates starting from 7/31/20 and ending at 5/31/21.

I have very limited experience with flows, and was hoping someone could advise on how to achieve the goal above. Any help would be greatly appreciated, so thanks in advance!

Best,
Tai
Tammer SalemTammer Salem
Hi,
You can use a flow for this - you will have to work with Collections and loop element. So a loop is what you will use to create a new record in memory (where you copy fields from an existing object, and change the close dates based on some logic). You will then place the "new recrd" into a collection. Then when you exit that loop you will use a create element and pass in the collection.

Here is a reference to Loops (https://help.salesforce.com/articleView?id=flow_ref_elements_loop.htm&type=5), and here is a reference to the Create element (https://help.salesforce.com/articleView?id=flow_ref_elements_data_create.htm&type=5) (where you will see something on creating more than one record). And finally here is something on Record Variable Collection (https://help.salesforce.com/articleView?id=flow_ref_resources_variable_populate.htm&type=5).

I would highly advise to got through this Trailhead module (Automate Your Business Processes with Lightning Flow (https://trailhead.salesforce.com/en/content/learn/trails/automate_business_processes))
It will take a while to go through it - but I gaurantee you that going through this trail you will be able to implement your requirement fairly easily.

Good luck!
Tai RahmanTai Rahman
Hi Tammer,

Thanks for your response! Based on your advice, I went through the Trailhead on Flows, and was able to build a flow which creates one opportunity record, containing the products from the original; with a close date that is 90 days from today (based on a formula field):

User-added image



Any chance you can advise on how to modify this, so that it creates 11 opportunities (instead of 1), with close dates that are 30 days apart from each iteration. I.e., if the first new record = 7/11/20, then the secon would be 8/11/20 and so forth.

Would really appreciate if you could provide any additional ideas. Thank you!