[SalesForce] Flow: Auto Create 12 Month Child Records From Parent Employee Record Using Flow

Using Process Builder to call the flow on record create.
I have a Contractor object. When a new Contractor is created, I need to auto create 12 (one per month) Time Sheet object records (regardless of what month or how many months left in the year, I still need 12 records created).
Each record will be for each month & has the Start & End of the Month (2 fields – both of which I can calculate using formulas).
Each new Time Sheet record will reference the Contractor (name & supervisor) directly from the parent record.
I looked into creating a single record using Process Builder & Cloning the record in flow, but couldn't figure out how to create the remaining 11 months.
I'm a flow novice so guidance is greatly appreciated.

Best Answer

You can create a loop counter which keeps count of number of records to create.

It will be similar to below flow

enter image description here

Step1: You create the process builder which calls the flow(contractor Id needs to be sent to the flow)

Step2: On the flow, You will lookup contractor id which was passed from process builder

Step3: Create a assignment variable and initializes it's value with 0

enter image description here Step4: A decision logic block to see if assignment variable < 12

enter image description here Step5: If true, create a new time sheet record. enter image description here

Step 6: Increment the Loop counter

enter image description here

Related Topic