Salesforce Create multiple child records based on a number field in the parent using flow

For this example, I'm using salesforce flow to create Ramp plans (child object) based on a number value field in opportunity (parent object)


The flow starts from a process builder after an Opportunity closed won

In here my number value field is Contract Term Length (In Months)

This is kind of a custom loop which iterate the Contract Term Length 


Final flow diagram



Start by creating an Auto launched flow



Let's create the variables we need to store the object data.


Note: Please check my previous post to get an idea to create variables you need.


First, we need to get the opportunity ID

To do that we are adding a Get Records element to the canvas

Then store the Opportunity Id on VarT_Opportunity ID



In the same panel allocate the value for VarT_ContractTermLength



Add a decision element 

Configure two outcomes as following






Then add an Assignment Element 

If the contract length is ok (greater than 0) Then we are first assigning the new ramp plan name and its related opportunity Id



Now we need to add the created Ramp plan to the Ramp plan collection which we finally going to insert.  Add another Assignment Element 




Then we reduce the length count by adding another Assignment Element 




Now you have an idea of how the custom loop works. This loop will work until the VarT_ContractTermLength become 0.
Which will then invoke the other decision - > To insert the collection

Once the Length is Zero, the flow will create the new collection of Ramp Plans.

Add Create Record Element



Then click Save and Activate the flow

After that, Create a new process builder. Follow the last part of blog post to understand creating a process builder. This time add only for Opportunity Close won.


Hope you will find this post useful :)

Comments

  1. Thank you for this post! Really helpful and nice step by step guide

    ReplyDelete

Post a Comment

Popular posts from this blog

How to fix SoapUI freeze in Mac OS

Salesforce Auto generate renewal Opportunity with Line Items (i.e. Opportunity Products)