Use Case: Auto-Generate Multiple Lines Of Opportunity Product

* Updated at Mar. 25, 2021. The original flow is not optimal for the performance.

This flow uses creating multiple lines of products as example, but it can be customized to work on all kinds of objects.

Lulu Mobile provides phone subscriptions and uses the standard Opportunity and Product objects to track their sales. They provide various subscription plans and has a model of “Commit for more years, get more discount”. The company is not using CPQ and wants to have a super clear overview of how many years each customer has committed to, thus they do not want to use Schedules and want to have one product line per year.

The problem can be solved by a screen flow, or a record-triggered flow with a custom field. Since we do not want to increase the time spent to add the products, we will choose the second method.

Create RecordsCounter
Update Records

Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!

Official Salesforce Help Article On Flow

Notify of

Newest Most Voted
Inline Feedbacks
View all comments

Saw you on Reddit… this looks awesome. Love to see a flow that sees a new record as a Lead and sends an email thanking them for filling out the form (that creates the lead on the web site) and checking out our web site. I used to be able to do this in Agile… haven’t quite figured out Salesforce yet, but I am learning.


Love the article and idea! I’m trying to implement it Order and OrderItem, but I’m getting Too Many SOQL queries when I use more than 5 in the How Many Lines field. Is there a way to build in a delay?


THANK YOU SO MUCH! This works perfectly!

I agree, need to optimize some other processes. Still learning 🙂


This is so great! It’s my first “official” flow. THANK YOU so much for the step-by-step instructions and screen shots!


Hi Melody,

I appreciate your straightforward, graphic flow explanations. Although an administrator for a some time I have found learning flow elusive. Hopefully will get better!

I have been trying to use your example as a template for my own flow but find myself getting stuck in one place- the dynamic date value is supposed to increment from each prior assignment value- but i’m finding the initial date formula value is set each time resulting in duplicates, rather than the previous incremented single record var date .

In my scenario the date increment is weekly and its an update flow from an initial record being set with a trigger being set from certain pick-list choices. I don’t have a number value that sets as the default base for the counter in a create scenario like you do. I also have native duplicate finder so this process fails (though i can see it in the debug)

The confusion for me is to have the formula incremented date in the single rec var be the object of the increment not the original next date formula repeated over and over again.

Do you have an idea what might be going awry here?

I have to admit that it was a little fuzzy for me analyzing your demo where I couldn’t figure out how this base date value was set in the first place given the date is not in the 1st assignment but rather the 2nd assignment where’s it’s the next date formula, along with the counter -1 that then passes to the collection var.

I think once I can have the first increment value being set on the first assignment to be set as the reference for the next date formula I will have this solved

Thanks for any help




Hi Melody, to break down your explanation, in your instance you update the formula first then update the variable with the value assigned in the formula and loop.

In my case, I would be updating the variable first (with whatever is supplying the first date to increment) then updating the variable with the formula value and loop

is that right?

The start value for your single record variable (or current value for the very first iteration) and what supplies that is key to what I’m missing I think. Because your initial assignment to the single record variable is not including the dynamic value for the Date,and somehow you are appending the incremented single record variable with that date on the 2nd assignment step and passing it thru to the collection variable from the single record variable then making your second pass with the same process.

Obviously your process works (your video proves it, ha!) I just need to somehow do the simplest version of this and build out. Thanks for your input/patience

Jon (aka Flow grasshopper)

PS The one thing that makes this moot unfortunately is that I now realize each iteration needs to populate the previous appt date field with the previous record id in chain of lookups between1-2-3-4. This is an after update scenario where the id is available after it is created – at least I think?

I don’t think these ids would available if I create all 4 at once, are they? i would need to be able to specify the right lookup id to each of the 4 new records.


Thanks Melody, I guess I need to take this one step at a time. succeed and then add a piece. At my level i don’t think there’s any other way. With so many things not working at once, I would be just building on confusion (as Bill Evans, the great jazz pianist once said)

Thanks again for your patience and input. Look forward to seeing your new posts.


Melody – question. Supposing the DML limits were not violated in multiple. create. How would the newly created record ID go for the next record to access in the lookup – where does that new Id go.? My assumption here is that the loop would be a cycle – Start – then a simple 3 part loop until counter is 0:

Decision —> Assignment (w/Decrement) —> Create —> Decision –> Assignment, etc

Or is that wrong?


Melody thanks!

But what how would you find these new variables created from the Create Records element if you were to look it up in Resources?
Does it have a standard systematic name?

Like here’s some made up ones:

{!CreatedRec1.Id} –>{!PrevApptVar1} —>CreatedRec2.PrevAppt__c
{!} —>{!PrevAppt?Var2} –>CreatedRec3.PrevAppt__c

something like this?


Hi Melody.

i think your video mostly explains it. it was how to identify the Created Record ID. In your example it looks like it explains it. And some of it will become more apparent if I connect more steps to the Created records on the canvas.

For the Collection Variable it’s not quite as clear how to segregate each ID so that you can then use them in a follow-up assignment step. (For example the one I described where the Previous Appt lookup on Record 2 is populated from Record 1). You did mention generally that it could be done with a counter and that you might do a follow-up if the public clamors for it (lol). Right now I’m one person 🙂 I want to try to take a stab at it. But of course I’m a beginner

Don’t mean to monopolize your thread here. i appreciate all your answers